"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[4880],{74880:(s,n,a)=>{a.r(n),a.d(n,{ChangePasswordPage:()=>j,default:()=>x});a(76687);var e,r,o=a(30415),i=a(53789),d=a(28781),t=a(77813),c=a(56481),l=a(45550),u=a(7053),w=a(55312),h=a(72e3),p=a(22729),g=a(52010);const f=s=>{var n,a;let{user:o,onChangePassword:i,isSaving:d}=s;const{disableLoginForm:f}=h.ZP,m=(null===(n=o.authLabels)||void 0===n?void 0:n.length)&&o.authLabels[0];return"LDAP"===m||"Auth Proxy"===m?e||(e=(0,g.jsx)("p",{children:"You cannot change password when signed in with LDAP or auth proxy."})):m&&f?r||(r=(0,g.jsx)("p",{children:"Password cannot be changed here."})):(0,g.jsx)("div",{className:t.css`
        max-width: 400px;
      `,children:(0,g.jsx)(c.l,{onSubmit:i,children:s=>{var n,e,r;let{register:o,errors:i,getValues:t}=s;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(l.g,{label:"Old password",invalid:!!i.oldPassword,error:null==i||null===(n=i.oldPassword)||void 0===n?void 0:n.message,children:(0,g.jsx)(p.Z,Object.assign({id:"current-password",autoComplete:"current-password"},o("oldPassword",{required:"Old password is required"})))}),(0,g.jsx)(l.g,{label:"New password",invalid:!!i.newPassword,error:null==i||null===(e=i.newPassword)||void 0===e?void 0:e.message,children:(0,g.jsx)(p.Z,Object.assign({id:"new-password",autoComplete:"new-password"},o("newPassword",{required:"New password is required",validate:{confirm:s=>s===t().confirmNew||"Passwords must match",old:s=>s!==t().oldPassword||"New password can't be the same as the old one."}})))}),(0,g.jsx)(l.g,{label:"Confirm password",invalid:!!i.confirmNew,error:null==i||null===(r=i.confirmNew)||void 0===r?void 0:r.message,children:(0,g.jsx)(p.Z,Object.assign({id:"confirm-new-password",autoComplete:"new-password"},o("confirmNew",{required:"New password confirmation is required",validate:s=>s===t().newPassword||"Passwords must match"})))}),(0,g.jsxs)(u.Lh,{children:[a||(a=(0,g.jsx)(w.zx,{variant:"primary",disabled:d,type:"submit",children:"Change Password"})),(0,g.jsx)(w.Qj,{variant:"secondary",href:`${h.ZP.appSubUrl}/profile`,fill:"outline",children:"Cancel"})]})]})}})})};var m,v=a(71884);const P={loadUser:v.II,changePassword:v.Cp};function j(s){let{loadUser:n,isUpdating:a,user:e,changePassword:r}=s;return(0,i.Z)((()=>n())),(0,g.jsx)(d.T,{navId:"profile/password",children:(0,g.jsx)(d.T.Contents,{isLoading:!Boolean(e),children:e?(0,g.jsxs)(g.Fragment,{children:[m||(m=(0,g.jsx)(d.T.OldNavOnly,{children:(0,g.jsx)("h3",{className:"page-sub-heading",children:"Change Your Password"})})),(0,g.jsx)(f,{user:e,onChangePassword:r,isSaving:a})]}):null})})}const x=(0,o.connect)((function(s){const n=s.user,{isUpdating:a,user:e}=n;return{isUpdating:a,user:e}}),P)(j)},71884:(s,n,a)=>{a.d(n,{Cp:()=>i,II:()=>t,Lj:()=>u,PA:()=>d,cc:()=>c,hz:()=>l});var e=a(67273),r=a(75541),o=a(18259);function i(s){return async function(n){n((0,o.zc)({updating:!0})),await r.h.changePassword(s),n((0,o.zc)({updating:!1}))}}function d(){return async function(s){await s(t()),s((async function(s){s((0,o.qD)());const n=await r.h.loadTeams();s((0,o.PL)({teams:n}))})),s((async function(s){s((0,o.$S)());const n=await r.h.loadOrgs();s((0,o.Ns)({orgs:n}))})),s((async function(s){s((0,o.Uk)());const n=await r.h.loadSessions();s((0,o.z0)({sessions:n}))}))}}function t(){return async function(s){const n=await r.h.loadUser();s((0,o.aw)({user:n}))}}function c(s){return async function(n){n((0,o.zc)({updating:!0})),await r.h.revokeUserSession(s),n((0,o.p$)({tokenId:s}))}}function l(s){return async function(n){n((0,o.zc)({updating:!0})),await r.h.setUserOrg(s),window.location.href=e.v.appSubUrl+"/profile"}}function u(s){return async function(n){n((0,o.zc)({updating:!0})),await r.h.updateUserProfile(s),await n(t()),n((0,o.zc)({updating:!1}))}}},53789:(s,n,a)=>{a.d(n,{Z:()=>r});var e=a(28465);const r=function(s){(0,e.Z)((function(){s()}))}}}]);
//# sourceMappingURL=4880.96f08b260c89141b32e6.js.map