"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6355],{16355:(L,d,a)=>{a.r(d),a.d(d,{ChangePasswordPage:()=>D,default:()=>S});var e=a(65237),o=a(37149),t=a(97504),r=a(38992),v=a(60234),i=a(46181),m=a(5263),p=a(6741),h=a(48389),E=a(18819),w=a(74245);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(4953);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)},4953:(L,d,a)=>{a.d(d,{Cp:()=>r,II:()=>i,Lj:()=>C,PA:()=>v,cc:()=>E,hz:()=>w});var e=a(49784),o=a(54184),t=a(89210);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}))}}},97504:(L,d,a)=>{a.d(d,{Z:()=>t});var e=a(11356),o=function(r){(0,e.Z)(function(){r()})};const t=o}}]);

//# sourceMappingURL=6355.deb3a867e7ae80884c1a.js.map