"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[465],{465:(z,d,s)=>{s.r(d),s.d(d,{ChangePasswordPage:()=>E,default:()=>O});var e=s(27702),o=s(27173),w=s(97990),l=s(44644),y=s(42844),U=s(23839),m=s(22209),C=s(64022),p=s(66670),v=s(12308),r=s(77597);const t=({user:c,onChangePassword:u,isSaving:i})=>{const{disableLoginForm:n}=v.default,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:(0,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.default.appSubUrl}/profile`,fill:"outline"},"Cancel")))))};var h=s(44501);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:!i},i?e.createElement(e.Fragment,null,e.createElement(t,{user:i,onChangePassword:n,isSaving:u})):null))}const O=L(E)},44501:(z,d,s)=>{s.d(d,{Cp:()=>h,hz:()=>u,PA:()=>S,II:()=>g,cc:()=>c,Lj:()=>i});var e=s(34667),o=s(73289);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(83341);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.config.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}))}}},97990:(z,d,s)=>{s.d(d,{Z:()=>w});var e=s(19559),o=function(l){(0,e.Z)(function(){l()})};const w=o}}]);

//# sourceMappingURL=465.25461b6dfc13fd2217f3.js.map