"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[5771],{75771:(L,d,a)=>{a.r(d),a.d(d,{ChangePasswordPage:()=>D,default:()=>S});var e=a(68404),o=a(36635),t=a(95700),r=a(79396),v=a(52423),i=a(94270),m=a(24799),p=a(52081),h=a(31403),E=a(47694),w=a(20787);const C=({user:c,onChangePassword:f,isSaving:l})=>{const{disableLoginForm:P}=E.ZP,U=c.authLabels?.length&&c.authLabels[0];return U==="LDAP"||U==="Auth Proxy"?e.createElement("p",null,"You cannot change password when signed in with LDAP or auth proxy."):U&&P?e.createElement("p",null,"Password cannot be changed here."):e.createElement("div",{className:v.css`
        max-width: 400px;
      `},e.createElement(i.l,{onSubmit:f},({register:O,errors:u,getValues:y})=>e.createElement(e.Fragment,null,e.createElement(m.g,{label:"Old password",invalid:!!u.oldPassword,error:u?.oldPassword?.message},e.createElement(w.Z,{id:"current-password",autoComplete:"current-password",...O("oldPassword",{required:"Old password is required"})})),e.createElement(m.g,{label:"New password",invalid:!!u.newPassword,error:u?.newPassword?.message},e.createElement(w.Z,{id:"new-password",autoComplete:"new-password",...O("newPassword",{required:"New password is required",validate:{confirm:g=>g===y().confirmNew||"Passwords must match",old:g=>g!==y().oldPassword||"New password can't be the same as the old one."}})})),e.createElement(m.g,{label:"Confirm password",invalid:!!u.confirmNew,error:u?.confirmNew?.message},e.createElement(w.Z,{id:"confirm-new-password",autoComplete:"new-password",...O("confirmNew",{required:"New password confirmation is required",validate:g=>g===y().newPassword||"Passwords must match"})})),e.createElement(p.Lh,null,e.createElement(h.zx,{variant:"primary",disabled:l,type:"submit"},"Change Password"),e.createElement(h.Qj,{variant:"secondary",href:`${E.ZP.appSubUrl}/profile`,fill:"outline"},"Cancel")))))};var n=a(20523);function s(c){const f=c.user,{isUpdating:l,user:P}=f;return{isUpdating:l,user:P}}const T={loadUser:n.II,changePassword:n.Cp},N=(0,o.connect)(s,T);function D({loadUser:c,isUpdating:f,user:l,changePassword:P}){return(0,t.Z)(()=>c()),e.createElement(r.T,{navId:"profile/password"},e.createElement(r.T.Contents,{isLoading:!Boolean(l)},l?e.createElement(e.Fragment,null,e.createElement(r.T.OldNavOnly,null,e.createElement("h3",{className:"page-sub-heading"},"Change Your Password")),e.createElement(C,{user:l,onChangePassword:P,isSaving:f})):null))}const S=N(D)},20523:(L,d,a)=>{a.d(d,{Cp:()=>r,II:()=>i,Lj:()=>C,PA:()=>v,cc:()=>E,hz:()=>w});var e=a(35645),o=a(19360),t=a(54294);function r(n){return async function(s){s((0,t.zc)({updating:!0})),await o.h.changePassword(n),s((0,t.zc)({updating:!1}))}}function v(){return async function(n){await n(i()),n(m()),n(p()),n(h())}}function i(){return async function(n){const s=await o.h.loadUser();n((0,t.aw)({user:s}))}}function m(){return async function(n){n((0,t.qD)());const s=await o.h.loadTeams();n((0,t.PL)({teams:s}))}}function p(){return async function(n){n((0,t.$S)());const s=await o.h.loadOrgs();n((0,t.Ns)({orgs:s}))}}function h(){return async function(n){n((0,t.Uk)());const s=await o.h.loadSessions();n((0,t.z0)({sessions:s}))}}function E(n){return async function(s){s((0,t.zc)({updating:!0})),await o.h.revokeUserSession(n),s((0,t.p$)({tokenId:n}))}}function w(n){return async function(s){s((0,t.zc)({updating:!0})),await o.h.setUserOrg(n),window.location.href=e.v.appSubUrl+"/profile"}}function C(n){return async function(s){s((0,t.zc)({updating:!0})),await o.h.updateUserProfile(n),await s(i()),s((0,t.zc)({updating:!1}))}}},95700:(L,d,a)=>{a.d(d,{Z:()=>t});var e=a(58252),o=function(r){(0,e.Z)(function(){r()})};const t=o}}]);

//# sourceMappingURL=5771.41af852f0d3989bb446f.js.map