32 lines
2.8 KiB
JavaScript
32 lines
2.8 KiB
JavaScript
import{u as x,o as S,q as y,ab as j,p as I,r as b,d as R,l,k as w,j as s,L as q,P as C,R as v,M as u,F as A,f as D,J as E,K as c,h as O}from"./main-CiAhdYQG.js";import{t as L,I as N,P as W}from"./password_changes-DaEmI9Wm.js";import{S as k}from"./Submit-DW2aiKTW.js";import{B as F}from"./ButtonLink-kWcKQZoZ.js";import{S as M}from"./Separator-CVNE-7yB.js";import"./_commonjsHelpers-DaWZu8wl.js";/* empty css */const $=w(`
|
|
mutation ChangePassword(
|
|
$userId: ID!
|
|
$oldPassword: String!
|
|
$newPassword: String!
|
|
) {
|
|
setPassword(
|
|
input: {
|
|
userId: $userId
|
|
currentPassword: $oldPassword
|
|
newPassword: $newPassword
|
|
}
|
|
) {
|
|
status
|
|
}
|
|
}
|
|
`),T=w(`
|
|
query PasswordChange {
|
|
viewer {
|
|
__typename
|
|
... on Node {
|
|
id
|
|
}
|
|
}
|
|
|
|
siteConfig {
|
|
...PasswordCreationDoubleInput_siteConfig
|
|
}
|
|
}
|
|
`),G=y({queryKey:["passwordChange"],queryFn:({signal:e})=>l({query:T,signal:e})});function Y(){const{t:e}=x(),{data:{viewer:n,siteConfig:p}}=S(G),h=j();if(n.__typename!=="User")throw I();const g=n.id,f=b.useRef(null),r=R({async mutationFn(a){const t=a.get("current_password"),i=a.get("new_password"),_=a.get("new_password_again");if(i!==_)throw new Error("passwords mismatch; this should be checked by the form");const d=await l({query:$,variables:{userId:g,oldPassword:t,newPassword:i}});return d.setPassword.status==="ALLOWED"&&h.navigate({to:"/password/change/success"}),d.setPassword}}),m=async a=>{a.preventDefault();const t=new FormData(a.currentTarget);r.mutate(t)},P=r.error!==null,o=L(e,r.data?.status);return s.jsx(q,{children:s.jsxs("div",{className:"flex flex-col gap-10",children:[s.jsx(C,{Icon:N,title:e("frontend.password_change.title"),subtitle:e("frontend.password_change.subtitle")}),s.jsxs(v,{onSubmit:m,method:"POST",children:[P&&s.jsx(u,{type:"critical",title:e("frontend.password_change.failure.title"),children:e("frontend.password_change.failure.description.unspecified")}),o!==void 0&&s.jsx(u,{type:"critical",title:e("frontend.password_change.failure.title"),children:o}),s.jsxs(A,{name:"current_password",serverInvalid:r.data?.status==="WRONG_PASSWORD",children:[s.jsx(D,{children:e("frontend.password_change.current_password_label")}),s.jsx(E,{required:!0,autoComplete:"current-password",ref:f}),s.jsx(c,{match:"valueMissing",children:e("frontend.errors.field_required")}),r.data&&r.data.status==="WRONG_PASSWORD"&&s.jsx(c,{children:e("frontend.password_change.failure.description.wrong_password")})]}),s.jsx(M,{}),s.jsx(W,{siteConfig:p,forceShowNewPasswordInvalid:r.data&&r.data.status==="INVALID_NEW_PASSWORD"||!1}),s.jsxs(k,{kind:"primary",disabled:r.isPending,children:[!!r.isPending&&s.jsx(O,{inline:!0}),e("action.save")]}),s.jsx(F,{to:"/",kind:"tertiary",children:e("action.cancel")})]})]})})}export{Y as component};
|
|
//# sourceMappingURL=password.change.index-DN6W0rA5.js.map
|