"use strict";(self.webpackChunk_as_client=self.webpackChunk_as_client||[]).push([[32],{9032:(e,a,t)=>{t.r(a),t.d(a,{default:()=>F});var n=t(8168),r=t(4041),s=t(6391),o=t(824),i=t(7973),l=t(3336),d=t(1879),m=t(6816),u=t(7894),c=t(9078),p=t(738),w=t(8081),g=t(5506);const h=w.Ay.div(["max-width:424px;margin:auto;@media (min-width:","px){max-width:456px;}"],p.nm.MD),f=(0,w.Ay)(g.A)(["justify-content:flex-end;width:100%;"]),b="Your confirmed password does not match the new password. Please re-enter both fields for accuracy.";function v(e){return"Password must contain at least {{passwordMinLength}} characters, an uppercase letter, lowercase letter, a digit and a symbol.".replace("{{passwordMinLength}}",e.toString())}function y({isStrongPasswordRequired:e,passwordMinLength:a}){const t=v(a);return{required:e?t:"New password is required.",validate:(n,{oldPassword:r})=>{const s=!e||function(e,a){return/[a-z]/.test(e)&&/[A-Z]/.test(e)&&/[0-9]/.test(e)&&/[^a-zA-Z0-9]/.test(e)&&e.length>=a}(n,a);return s?n!==r||"New password is the same as the old.":t}}}const A=e=>{const{error:a,disabled:t,isStrongPasswordRequired:n,passwordMinLength:s=8,onSubmit:p,onCancel:w}=e,{handleSubmit:g,formState:{isValid:A},control:x,watch:C}=(0,o.mN)({mode:"onTouched"}),S=(0,o.as)({control:x,name:"oldPassword",rules:{required:"Current password is required."}}),E=(0,o.as)({control:x,name:"newPassword",rules:y({isStrongPasswordRequired:n,passwordMinLength:s})}),P=(0,o.as)({control:x,name:"newPasswordConfirm",rules:{required:b,validate:(e,{newPassword:a})=>e===a||b}}),[M,q]=(0,r.useState)(!1),_=n?v(s):void 0;return(0,r.useEffect)((()=>{const e=C((()=>q(!1)));return()=>e.unsubscribe()}),[C]),(0,r.useEffect)((()=>q(Boolean(a))),[a]),r.createElement(h,null,r.createElement(u.Z,null,r.createElement(c.H1,null,"Change password"),r.createElement("form",{id:"password-reset-form",name:"password-reset-form",onSubmit:g(p)},r.createElement("div",{style:{marginBottom:"1rem"}},r.createElement(l.A,{onChange:S.field.onChange,onBlur:S.field.onBlur,value:S.field.value,required:!0,"data-testid":"current-password",title:"Current Password",id:S.field.name,name:S.field.name,"aria-disabled":t,disabled:t,autoComplete:"new-password",error:S.fieldState.invalid,description:S.fieldState.error?.message,fullWidth:!0})),r.createElement("div",{style:{marginBottom:"1rem"}},r.createElement(l.A,{onChange:E.field.onChange,onBlur:E.field.onBlur,value:E.field.value,required:!0,"data-testid":"new-password",title:"New Password",id:E.field.name,name:E.field.name,"aria-disabled":t,disabled:t,autoComplete:"new-password",error:E.fieldState.invalid,description:E.fieldState.error?.message||_,fullWidth:!0})),r.createElement("div",{style:{marginBottom:"2rem"}},r.createElement(l.A,{onChange:P.field.onChange,onBlur:P.field.onBlur,value:P.field.value,required:!0,"data-testid":"confirm-new-password",title:"Confirm New Password",id:P.field.name,name:P.field.name,"aria-disabled":t,disabled:t,autoComplete:"new-password",error:P.fieldState.invalid,description:P.fieldState.error?.message,fullWidth:!0}),M&&r.createElement(d.A,{mt:16},r.createElement(m.A,{title:"",variant:"warning"},a))),r.createElement(f,{p:0,disableElevation:!0},r.createElement(i.A,{type:"submit",variant:"primary",disabled:!A||t,"data-testid":"submit-password-reset","aria-label":"Update Password"},"Update Password"),r.createElement(i.A,{type:"button",variant:"ghost",disabled:t,"data-testid":"cancel-password-reset",onClick:w,"aria-label":"Cancel"},"Cancel")))))};var x=t(5353),C=t(306),S=t(5772),E=t(6319),P=t(8658),M=t(1411),q=t(730),_=t(5765),k=t(6606),B=t(3614),W=t(8155),L=t(9594);var T=t(9649);const R=(0,w.Ay)(T.A)(["background:transparent;",""],p.Ay.lessThen(p.nm.SM)`
        background: #fff;
    `),F=()=>{const{mfaChallenge:e,isPasswordChangeAllowed:a,onMFAChallengeSubmit:t,...o}=function(){const e=(0,s.W6)(),[a,t]=(0,r.useState)(""),n=(0,L.GV)(C.e2),{username:o,allow_password_change:i,password_reset:l,enforce_strong_passwords:d}=n,m=(0,L.GV)(C.oq),[u,c]=(0,r.useState)(""),p=(0,L.jL)(),[w,{isLoading:g}]=(0,S.I8)(),[h,{isLoading:f}]=(0,S.SV)(),[b,{isLoading:v}]=(0,S.mg)(),{data:y,isLoading:A}=(0,W.Jx)(),x=(e,a)=>{let n=!1;(0,E.W)(e)&&((0,P.x)(e.data)?(p((0,M.wF)(e.data)),n=!0):(0,q.Z)(e.data)&&(t(e.data.reason),n=!0)),n||t(a)},T=async(a,t)=>{const{auth_token:n,username:r}=t;try{await h({newPassword:a,token:n,userName:r}).unwrap(),c(""),p((0,M.wF)(void 0)),document.forms.item(0)?.reset(),_.o.success("Password changed"),e.push(B.f.downloads)}catch(e){x(e,"Failed to change password")}},R=()=>{const e="expired"===(0,k.b)(n);return e&&p((0,M.vw)()),e};return{disabled:g||v||f||A,error:a,mfaChallenge:m,isStrongPasswordRequired:d,isPasswordChangeAllowed:i,passwordMinLength:y?.password_min_len,onSubmit:async e=>{if(R())return;t("");const{newPassword:a,oldPassword:n}=e;c(a);const r=await(async(e,a)=>{try{const t=await w({username:e,password:a}).unwrap();return p((0,M.Wj)(t)),t.allow_password_change?t:(_.o.error("Password change is not allowed."),null)}catch(e){x(e,"Failed to login with old credentials")}return null})(o,n);r&&T(a,r)},onCancel:()=>{l||e.goBack()},onMFAChallengeSubmit:async e=>{if(R())return;const a={challenge_context:m?.challenge_context||"",response:e,username:o};try{const e=await b(a).unwrap();p((0,M.Wj)(e)),T(u,e)}catch(e){_.o.error("Challenge failed."),p((0,M.wF)(void 0))}}}}();return a?r.createElement(r.Fragment,null,r.createElement(A,o),!!e&&r.createElement(R,{open:!0,persistent:!0,closeOnClickOutside:!1},r.createElement(x.Q,(0,n.A)({onSubmit:t,onCancel:()=>{}},e,{disabled:o.disabled,error:o.error})))):r.createElement(s.rd,{to:"/"})}},5772:(e,a,t)=>{t.d(a,{BB:()=>l,I8:()=>i,Ir:()=>u,Km:()=>p,SV:()=>m,eR:()=>c,mg:()=>d});var n=t(323),r=t(6270),s=t(5167);const o=t(2644).U.injectEndpoints({endpoints:e=>({loginWithEmailAndPassword:e.mutation({query:e=>({url:n.M.login,method:"POST",body:e}),transformResponse:e=>(0,s.d)(e)}),loginWithSaml:e.mutation({query:e=>({url:n.M.samlAssertion,method:"POST",body:e}),transformResponse:e=>(0,s.d)(e)}),vpnSamlAuth:e.mutation({query:e=>({url:n.M.vpnSamlAuth,method:"POST",body:e})}),getIdpUrl:e.query({query:e=>({url:n.M.getIdpUrl,params:{relay_state:e}})}),submitMfaChallenge:e.mutation({query:e=>({url:n.M.mfaChallenge,method:"POST",body:e}),transformResponse:e=>(0,s.d)(e)}),changePassword:e.mutation({query:({newPassword:e,token:a,userName:t})=>({url:n.M.passwordChange,method:"POST",body:{username:t,new_password:e},headers:{[r.j]:a}})}),enrollInMfa:e.mutation({query:({token:e,authToken:a})=>({url:n.M.mfaEnroll,method:"POST",body:{token:e},headers:{[r.j]:a}}),transformResponse:e=>(0,s.d)(e)})})}),{useLoginWithEmailAndPasswordMutation:i,useLoginWithSamlMutation:l,useSubmitMfaChallengeMutation:d,useChangePasswordMutation:m,useEnrollInMfaMutation:u,useLazyGetIdpUrlQuery:c,useVpnSamlAuthMutation:p}=o},8658:(e,a,t)=>{function n(e){return"object"==typeof e&&null!==e&&Reflect.has(e,"challenge_context")}t.d(a,{x:()=>n})},7894:(e,a,t)=>{t.d(a,{Z:()=>m});var n=t(4041),r=t(8081),s=t(9192),o=t(3580),i=t(738);const l=(0,r.AH)(["margin-right:auto;margin-left:auto;"]),d=r.Ay.div([""," max-width:",";padding:var(--spacing-md,32px) var(--spacing-xs,16px);background:#fff;border:1px solid ",";border-radius:1rem;"," ",""],(0,s.A)("centered")`
       ${l}
    `,(({maxWidth:e})=>(e=>{if(void 0!==e)return"number"==typeof e?`${e}px`:e})(e)),o.A.neutralBorder,i.Ay.moreThen(i.nm.SM)`
        padding: var(--spacing-md, 32px);
        ${(0,s.A)("withShadow")`
            box-shadow: 0px 1px 3px rgba(16, 24, 40, 0.1), 0px 1px 2px rgba(16, 24, 40, 0.06);
        `}
    `,i.Ay.moreThen(i.nm.MD)`
        padding: var(--spacing-md, 32px) var(--spacing-lg, 48px);
    `),m=e=>{const{children:a,...t}=e;return n.createElement(d,t,a)}},5353:(e,a,t)=>{t.d(a,{Q:()=>h});var n=t(9690),r=t(4041),s=t(8255),o=t(3578),i=t(7973),l=t(7894),d=t(9078),m=t(8081),u=t(5506);const c=m.Ay.div(["max-width:456px;margin:auto;text-align:center;"]),p=m.Ay.div(["margin-bottom:var(--spacing-md,32px);text-align:left;"]),w=(0,m.Ay)(u.A)(["margin-bottom:2rem;"]),g=e=>{const{echo:a,...t}=e;return r.createElement(s.A,(0,n.A)({},t,{type:a?"text":"password"}))},h=e=>{const{challenge:a,echo:t,disabled:n,error:s,onCancel:m,onSubmit:u}=e,[h,f]=(0,r.useState)(""),b=Boolean(s);return r.createElement(c,null,r.createElement(l.Z,null,r.createElement(d.H1,{mb:"var(--spacing-xxxs, 4px)"},"MFA"),r.createElement(o.A,{mb:"var(--spacing-md, 32px)",variant:"textMd",inline:!1},"Please answer your security question"),r.createElement("form",{id:"mfa-challenge-form",name:"mfa-challenge-form",onSubmit:e=>{e.preventDefault(),u(h)}},r.createElement(p,null,r.createElement(g,{id:"answer",name:"answer",value:h,echo:t,fullWidth:!0,disabled:n,"aria-disabled":n,autoComplete:"new-password",onChange:f,"data-testid":"answer",error:b,title:a,description:s})),r.createElement(w,{fullWidth:!0},r.createElement(i.A,{variant:"primary",type:"submit",disabled:n||!h,"aria-disabled":!(!n&&h)||void 0,"data-testid":"submit-mfa-challenge","aria-label":"Confirm",fullWidth:!0},"Confirm"),r.createElement(i.A,{variant:"ghost",type:"button",disabled:n,"aria-disabled":!!n||void 0,onClick:m,"data-testid":"cancel-mfa-challenge","aria-label":"Cancel",fullWidth:!0},"Cancel")))))}},9078:(e,a,t)=>{t.d(a,{H1:()=>m});var n=t(9690),r=t(4041),s=t(3580),o=t(8081),i=t(3578),l=t(738);const d=(0,o.Ay)(i.A)(["margin-top:0;margin-bottom:var(--spacing-md,32);letter-spacing:-0.64px;",""],l.Ay.lessThen(l.nm.MD-1)`
        margin-bottom: var(--spacing-sm, 24);
        font-size: 24px;
        line-height: 32px;
        letter-spacing: -0.48px;
    `),m=e=>r.createElement(d,(0,n.A)({color:s.A.neutralTextTitle,inline:!1,variant:"displayLg",center:!0,weight:"semiBold"},e))}}]);