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

//# sourceMappingURL=5771.116ef060e85d5bcbf7f4.js.map