"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[7834],{80986:(F,d,s)=>{s.r(d),s.d(d,{ChangePasswordPage:()=>v,default:()=>O});var n=s(39953),t=s(89772),w=s(69047),l=s(13253),E=s(41407),y=s(85830),f=s(96227),C=s(12223),g=s(4919),h=s(50820),o=s(62679),r=s(61992);const U=({user:i,onChangePassword:c,isSaving:e})=>{const{disableLoginForm:a}=h.default,T=i.authLabels?.length&&i.authLabels[0];return T==="LDAP"||T==="Auth Proxy"?n.createElement("p",null,n.createElement(o.cC,{i18nKey:"profile.change-password.ldap-auth-proxy-message"},"You cannot change password when signed in with LDAP or auth proxy.")):T&&a?n.createElement("p",null,n.createElement(o.cC,{i18nKey:"profile.change-password.cannot-change-password-message"},"Password cannot be changed here.")):n.createElement("div",{className:(0,E.css)`
        max-width: 400px;
      `},n.createElement(y.l,{onSubmit:c},({register:z,errors:u,getValues:N})=>n.createElement(n.Fragment,null,n.createElement(f.g,{label:(0,o.t)("profile.change-password.old-password-label","Old password"),invalid:!!u.oldPassword,error:u?.oldPassword?.message},n.createElement(r.Z,{id:"current-password",autoComplete:"current-password",...z("oldPassword",{required:(0,o.t)("profile.change-password.old-password-required","Old password is required")})})),n.createElement(f.g,{label:(0,o.t)("profile.change-password.new-password-label","New password"),invalid:!!u.newPassword,error:u?.newPassword?.message},n.createElement(r.Z,{id:"new-password",autoComplete:"new-password",...z("newPassword",{required:(0,o.t)("profile.change-password.new-password-required","New password is required"),validate:{confirm:m=>m===N().confirmNew||(0,o.t)("profile.change-password.passwords-must-match","Passwords must match"),old:m=>m!==N().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(f.g,{label:(0,o.t)("profile.change-password.confirm-password-label","Confirm password"),invalid:!!u.confirmNew,error:u?.confirmNew?.message},n.createElement(r.Z,{id:"confirm-new-password",autoComplete:"new-password",...z("confirmNew",{required:(0,o.t)("profile.change-password.confirm-password-required","New password confirmation is required"),validate:m=>m===N().newPassword||(0,o.t)("profile.change-password.passwords-must-match","Passwords must match")})})),n.createElement(C.Lh,null,n.createElement(g.zx,{variant:"primary",disabled:e,type:"submit"},n.createElement(o.cC,{i18nKey:"profile.change-password.change-password-button"},"Change Password")),n.createElement(g.Qj,{variant:"secondary",href:`${h.default.appSubUrl}/profile`,fill:"outline"},n.createElement(o.cC,{i18nKey:"profile.change-password.cancel-button"},"Cancel"))))))};var P=s(94240);function p(i){const c=i.user,{isUpdating:e,user:a}=c;return{isUpdating:e,user:a}}const S={loadUser:P.II,changePassword:P.Cp},L=(0,t.connect)(p,S);function v({loadUser:i,isUpdating:c,user:e,changePassword:a}){return(0,w.Z)(()=>i()),n.createElement(l.T,{navId:"profile/password"},n.createElement(l.T.Contents,{isLoading:!e},e?n.createElement(n.Fragment,null,n.createElement(U,{user:e,onChangePassword:a,isSaving:c})):null))}const O=L(v)},94240:(F,d,s)=>{s.d(d,{Cp:()=>U,hz:()=>i,PA:()=>P,II:()=>p,cc:()=>O,Lj:()=>c});var n=s(32688),t=s(4148);async function w(e){try{await(0,t.i)().put("/api/user/password",e)}catch(a){console.error(a)}}function l(){return(0,t.i)().get("/api/user")}function E(){return(0,t.i)().get("/api/user/teams")}function y(){return(0,t.i)().get("/api/user/orgs")}function f(){return(0,t.i)().get("/api/user/auth-tokens")}async function C(e){await(0,t.i)().post("/api/user/revoke-auth-token",{authTokenId:e})}async function g(e){await(0,t.i)().post("/api/user/using/"+e.orgId,{})}async function h(e){try{await(0,t.i)().put("/api/user",e)}catch(a){console.error(a)}}const o={changePassword:w,revokeUserSession:C,loadUser:l,loadSessions:f,loadOrgs:y,loadTeams:E,setUserOrg:g,updateUserProfile:h};var r=s(16920);function U(e){return async function(a){a((0,r.zc)({updating:!0})),await o.changePassword(e),a((0,r.zc)({updating:!1}))}}function P(){return async function(e){await e(p()),e(S()),e(L()),e(v())}}function p(){return async function(e){const a=await o.loadUser();e((0,r.aw)({user:a}))}}function S(){return async function(e){e((0,r.qD)());const a=await o.loadTeams();e((0,r.PL)({teams:a}))}}function L(){return async function(e){e((0,r.$S)());const a=await o.loadOrgs();e((0,r.Ns)({orgs:a}))}}function v(){return async function(e){e((0,r.Uk)());const a=await o.loadSessions();e((0,r.z0)({sessions:a}))}}function O(e){return async function(a){a((0,r.zc)({updating:!0})),await o.revokeUserSession(e),a((0,r.p$)({tokenId:e}))}}function i(e){return async function(a){a((0,r.zc)({updating:!0})),await o.setUserOrg(e),window.location.href=n.config.appSubUrl+"/profile"}}function c(e){return async function(a){a((0,r.zc)({updating:!0})),await o.updateUserProfile(e),await a(p()),a((0,r.zc)({updating:!1}))}}},69047:(F,d,s)=>{s.d(d,{Z:()=>w});var n=s(45580),t=function(l){(0,n.Z)(function(){l()})};const w=t}}]);

//# sourceMappingURL=7834.9a943ac91d710a40cde6.js.map