"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[8107],{28107:(L,d,s)=>{s.r(d),s.d(d,{ChangePasswordPage:()=>v,default:()=>S});var n=s(96540),t=s(69733),w=s(4392),l=s(36830),y=s(32196),E=s(51253),m=s(88575),A=s(66864),g=s(55852),h=s(2913),o=s(44836),r=s(78361);const U=({user:i,onChangePassword:c,isSaving:e})=>{const{disableLoginForm:a}=h.Ay,O=i.authLabels?.length&&i.authLabels[0];return O==="LDAP"||O==="Auth Proxy"?n.createElement("p",null,n.createElement(o.x6,{i18nKey:"profile.change-password.ldap-auth-proxy-message"},"You cannot change password when signed in with LDAP or auth proxy.")):O&&a?n.createElement("p",null,n.createElement(o.x6,{i18nKey:"profile.change-password.cannot-change-password-message"},"Password cannot be changed here.")):n.createElement("div",{className:(0,y.css)`
        max-width: 400px;
      `},n.createElement(E.l,{onSubmit:c},({register:I,errors:u,getValues:D})=>n.createElement(n.Fragment,null,n.createElement(m.D,{label:(0,o.t)("profile.change-password.old-password-label","Old password"),invalid:!!u.oldPassword,error:u?.oldPassword?.message},n.createElement(r.s,{id:"current-password",autoComplete:"current-password",...I("oldPassword",{required:(0,o.t)("profile.change-password.old-password-required","Old password is required")})})),n.createElement(m.D,{label:(0,o.t)("profile.change-password.new-password-label","New password"),invalid:!!u.newPassword,error:u?.newPassword?.message},n.createElement(r.s,{id:"new-password",autoComplete:"new-password",...I("newPassword",{required:(0,o.t)("profile.change-password.new-password-required","New password is required"),validate:{confirm:p=>p===D().confirmNew||(0,o.t)("profile.change-password.passwords-must-match","Passwords must match"),old:p=>p!==D().oldPassword||(0,o.t)("profile.change-password.new-password-same-as-old","New password can't be the same as the old one.")}})})),n.createElement(m.D,{label:(0,o.t)("profile.change-password.confirm-password-label","Confirm password"),invalid:!!u.confirmNew,error:u?.confirmNew?.message},n.createElement(r.s,{id:"confirm-new-password",autoComplete:"new-password",...I("confirmNew",{required:(0,o.t)("profile.change-password.confirm-password-required","New password confirmation is required"),validate:p=>p===D().newPassword||(0,o.t)("profile.change-password.passwords-must-match","Passwords must match")})})),n.createElement(A.Gy,null,n.createElement(g.$n,{variant:"primary",disabled:e,type:"submit"},n.createElement(o.x6,{i18nKey:"profile.change-password.change-password-button"},"Change Password")),n.createElement(g.z9,{variant:"secondary",href:`${h.Ay.appSubUrl}/profile`,fill:"outline"},n.createElement(o.x6,{i18nKey:"profile.change-password.cancel-button"},"Cancel"))))))};var P=s(84969);function f(i){const c=i.user,{isUpdating:e,user:a}=c;return{isUpdating:e,user:a}}const C={loadUser:P.YW,changePassword:P.ec},N=(0,t.connect)(f,C);function v({loadUser:i,isUpdating:c,user:e,changePassword:a}){return(0,w.A)(()=>i()),n.createElement(l.Y,{navId:"profile/password"},n.createElement(l.Y.Contents,{isLoading:!e},e?n.createElement(n.Fragment,null,n.createElement(U,{user:e,onChangePassword:a,isSaving:c})):null))}const S=N(v)},84969:(L,d,s)=>{s.d(d,{ec:()=>U,Aj:()=>i,Qe:()=>P,YW:()=>f,_O:()=>S,eg:()=>c});var n=s(32264),t=s(17172);async function w(e){try{await(0,t.AI)().put("/api/user/password",e)}catch(a){console.error(a)}}function l(){return(0,t.AI)().get("/api/user")}function y(){return(0,t.AI)().get("/api/user/teams")}function E(){return(0,t.AI)().get("/api/user/orgs")}function m(){return(0,t.AI)().get("/api/user/auth-tokens")}async function A(e){await(0,t.AI)().post("/api/user/revoke-auth-token",{authTokenId:e})}async function g(e){await(0,t.AI)().post("/api/user/using/"+e.orgId,{})}async function h(e){try{await(0,t.AI)().put("/api/user",e)}catch(a){console.error(a)}}const o={changePassword:w,revokeUserSession:A,loadUser:l,loadSessions:m,loadOrgs:E,loadTeams:y,setUserOrg:g,updateUserProfile:h};var r=s(81862);function U(e){return async function(a){a((0,r.Nm)({updating:!0})),await o.changePassword(e),a((0,r.Nm)({updating:!1}))}}function P(){return async function(e){await e(f()),e(C()),e(N()),e(v())}}function f(){return async function(e){const a=await o.loadUser();e((0,r.HO)({user:a}))}}function C(){return async function(e){e((0,r.ri)());const a=await o.loadTeams();e((0,r.Q9)({teams:a}))}}function N(){return async function(e){e((0,r.Mj)());const a=await o.loadOrgs();e((0,r.ny)({orgs:a}))}}function v(){return async function(e){e((0,r.uh)());const a=await o.loadSessions();e((0,r.RS)({sessions:a}))}}function S(e){return async function(a){a((0,r.Nm)({updating:!0})),await o.revokeUserSession(e),a((0,r.g$)({tokenId:e}))}}function i(e){return async function(a){a((0,r.Nm)({updating:!0})),await o.setUserOrg(e),window.location.href=n.$.appSubUrl+"/profile"}}function c(e){return async function(a){a((0,r.Nm)({updating:!0})),await o.updateUserProfile(e),await a(f()),a((0,r.Nm)({updating:!1}))}}},4392:(L,d,s)=>{s.d(d,{A:()=>w});var n=s(94701),t=function(l){(0,n.A)(function(){l()})};const w=t}}]);

//# sourceMappingURL=8107.92bd414247a1d05c014f.js.map