"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[6788],{26788:(n,s,a)=>{a.r(s),a.d(s,{ChangePasswordPage:()=>v,default:()=>P});a(68404);var e,r,o=a(18745),i=a(57686),d=a(33801),t=a(8674),c=a(36636),l=a(69783),u=a(78837),w=a(45653),h=a(45916);const p=n=>{var s,a;let{user:o,onChangePassword:i,isSaving:d}=n;const{ldapEnabled:t,authProxyEnabled:p,disableLoginForm:g}=u.ZP,f=(null===(s=o.authLabels)||void 0===s?void 0:s.length)&&o.authLabels[0];return t||p?e||(e=(0,h.jsx)("p",{children:"You cannot change password when LDAP or auth proxy authentication is enabled."})):f&&g?r||(r=(0,h.jsx)("p",{children:"Password cannot be changed here."})):(0,h.jsx)("div",{className:c.css`
        max-width: 400px;
      `,children:(0,h.jsx)(l.Form,{onSubmit:i,children:n=>{var s,e,r;let{register:o,errors:i,getValues:t}=n;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l.Field,{label:"Old password",invalid:!!i.oldPassword,error:null==i||null===(s=i.oldPassword)||void 0===s?void 0:s.message,children:(0,h.jsx)(w.Z,Object.assign({id:"current-password",autoComplete:"current-password"},o("oldPassword",{required:"Old password is required"})))}),(0,h.jsx)(l.Field,{label:"New password",invalid:!!i.newPassword,error:null==i||null===(e=i.newPassword)||void 0===e?void 0:e.message,children:(0,h.jsx)(w.Z,Object.assign({id:"new-password",autoComplete:"new-password"},o("newPassword",{required:"New password is required",validate:{confirm:n=>n===t().confirmNew||"Passwords must match",old:n=>n!==t().oldPassword||"New password can't be the same as the old one."}})))}),(0,h.jsx)(l.Field,{label:"Confirm password",invalid:!!i.confirmNew,error:null==i||null===(r=i.confirmNew)||void 0===r?void 0:r.message,children:(0,h.jsx)(w.Z,Object.assign({id:"confirm-new-password",autoComplete:"new-password"},o("confirmNew",{required:"New password confirmation is required",validate:n=>n===t().newPassword||"Passwords must match"})))}),(0,h.jsxs)(l.HorizontalGroup,{children:[a||(a=(0,h.jsx)(l.Button,{variant:"primary",disabled:d,type:"submit",children:"Change Password"})),(0,h.jsx)(l.LinkButton,{variant:"secondary",href:`${u.ZP.appSubUrl}/profile`,fill:"outline",children:"Cancel"})]})]})}})})};var g,f=a(86706);const m={loadUser:f.II,changePassword:f.Cp};function v(n){let{navModel:s,loadUser:a,isUpdating:e,user:r,changePassword:o}=n;return(0,i.Z)((()=>a())),(0,h.jsx)(d.Z,{navModel:s,children:(0,h.jsx)(d.Z.Contents,{isLoading:!Boolean(r),children:r?(0,h.jsxs)(h.Fragment,{children:[g||(g=(0,h.jsx)("h3",{className:"page-heading",children:"Change Your Password"})),(0,h.jsx)(p,{user:r,onChangePassword:o,isSaving:e})]}):null})})}const P=(0,o.connect)((function(n){const s=n.user,{isUpdating:a,user:e}=s;return{navModel:(0,t.h)(n.navIndex,"change-password"),isUpdating:a,user:e}}),m)(v)},86706:(n,s,a)=>{a.d(s,{Cp:()=>i,II:()=>t,Lj:()=>u,PA:()=>d,cc:()=>c,hz:()=>l});var e=a(90923),r=a(67220),o=a(10603);function i(n){return async function(s){s((0,o.zc)({updating:!0})),await r.h.changePassword(n),s((0,o.zc)({updating:!1}))}}function d(){return async function(n){await n(t()),n((async function(n){n((0,o.qD)());const s=await r.h.loadTeams();n((0,o.PL)({teams:s}))})),n((async function(n){n((0,o.$S)());const s=await r.h.loadOrgs();n((0,o.Ns)({orgs:s}))})),n((async function(n){n((0,o.Uk)());const s=await r.h.loadSessions();n((0,o.z0)({sessions:s}))}))}}function t(){return async function(n){const s=await r.h.loadUser();n((0,o.aw)({user:s}))}}function c(n){return async function(s){s((0,o.zc)({updating:!0})),await r.h.revokeUserSession(n),s((0,o.p$)({tokenId:n}))}}function l(n){return async function(s){s((0,o.zc)({updating:!0})),await r.h.setUserOrg(n),window.location.href=e.config.appSubUrl+"/profile"}}function u(n){return async function(s){s((0,o.zc)({updating:!0})),await r.h.updateUserProfile(n),await s(t()),s((0,o.zc)({updating:!1}))}}},57686:(n,s,a)=>{a.d(s,{Z:()=>r});var e=a(37784);const r=function(n){(0,e.Z)((function(){n()}))}}}]);
//# sourceMappingURL=6788.026b7d1291c2c51c9d98.js.map