3 lines
5.4 KiB
JavaScript
3 lines
5.4 KiB
JavaScript
import"../chunks/DsnmJJEf.js";import{p as Ne,u as Te,t as p,a as m,b as he,k as Re,c as E,d as s,$ as Ie,r as o,s as d,g as r,h as W,l as De,e as q,f as w,j as v,n as we,i as S}from"../chunks/krC2xWPP.js";import{d as Ae,a as ye,s as _,e as Me}from"../chunks/CddAxf8c.js";import{i as N}from"../chunks/DjsWWzyL.js";import{h as Pe}from"../chunks/DSIsCMt7.js";import{h as Oe,s as ke}from"../chunks/j_DJpx8B.js";import{s as Q,r as Xe,B as Le,t as T}from"../chunks/Lvd_r9sp.js";import{b as Ce}from"../chunks/ciapVzar.js";import{i as n}from"../chunks/Cu5ilWky.js";import{g as Ge}from"../chunks/BVTiZ3e2.js";import{b as Y}from"../chunks/BSopV7IU.js";import{p as J}from"../chunks/euuZp6ft.js";import{r as We}from"../chunks/CNrnzl73.js";import{D as ze}from"../chunks/nlum2O0L.js";import{B as Be,t as Z}from"../chunks/BzsopytP.js";import{p as z,P as Ke,e as $e}from"../chunks/DI46g3k0.js";import{S as je,M as Ue}from"../chunks/BrVNO555.js";import{L as Fe}from"../chunks/C_E2vM9U.js";import{K as He}from"../chunks/B51cP8nR.js";var Ve=E('<div class="px-6 py-5 text-center text-[0.8125rem] text-muted-foreground"> </div>'),qe=E('<p class="text-xs text-red-500"> </p>'),Qe=E("<!> ",1),Ye=E("<!> Reset password",1),Je=E('<form class="space-y-4 px-6 py-5" novalidate=""><!> <div class="space-y-1.5"><label for="confirm" class="text-[0.8125rem] font-medium text-foreground"> </label> <input id="confirm" type="password" autocomplete="new-password"/> <!></div> <!></form>'),Ze=E('<div class="flex min-h-screen items-center justify-center bg-background p-4"><button type="button" class="absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"><!></button> <div class="w-full max-w-sm"><div class="mb-8 flex flex-col items-center text-center"><div class="mb-4"><!></div> <h1 class="text-2xl font-semibold tracking-tight text-foreground"> </h1> <p class="mt-1 text-[0.8125rem] text-muted-foreground"><!></p></div> <div class="rounded-lg border border-border bg-card shadow-sm"><!> <div class="border-t border-border px-6 py-3"><a class="flex items-center justify-center gap-1.5 text-[0.75rem] font-medium text-muted-foreground transition-colors hover:text-foreground"><!> </a></div></div></div></div>');function br(ee,re){Ne(re,!0);const A=W(()=>J.url.searchParams.get("user")??""),B=W(()=>J.url.searchParams.get("token")??"");let u=S(""),y=S(""),c=S(!1),M=S(!1),h=S(!1);Te(()=>{z.load().catch(()=>{})});const K=W(()=>!r(A)||!r(B));async function te(e){e.preventDefault(),v(M,!1),v(h,!1);const t=$e(r(u),z.current);if(!r(u)||!t.allRulesMet){v(M,!0);return}if(r(u)!==r(y)){v(h,!0);return}v(c,!0);try{await We(r(A),r(B),r(u)),T.success(n.t("ADMIN_NEXT.RESET.PASSWORD_RESET_SUCCESSFULLY_PLEASE_SIGN")),Ge(`${Y}/login`)}catch(a){if(a&&typeof a=="object"&&"status"in a){const i=a;i.status===429?T.error(i.message||"Too many attempts. Try again later."):i.status===422||i.status===400?T.error(i.message||"Invalid or expired reset link."):T.error(i.message||"Unable to reset password")}else T.error(n.t("ADMIN_NEXT.RESET.UNABLE_TO_CONNECT_TO_SERVER"))}finally{v(c,!1)}}var P=Ze();Oe("1rnsd0w",e=>{Re(t=>{Ie.title=t??""},[()=>n.t("ADMIN_NEXT.RESET.RESET_PASSWORD_GRAV_ADMIN")])});var g=s(P),ae=s(g);{var se=e=>{je(e,{size:16})},oe=e=>{Ue(e,{size:16})};N(ae,e=>{Z.isDark?e(se):e(oe,-1)})}o(g);var $=d(g,2),O=s($),k=s(O),ie=s(k);Be(ie,{size:"login"}),o(k);var X=d(k,2),ne=s(X,!0);o(X);var j=d(X,2),le=s(j);{var de=e=>{var t=De();p(a=>_(t,a),[()=>n.t("ADMIN_NEXT.RESET.INVALID_LINK")]),m(e,t)},me=e=>{var t=q(),a=w(t);Pe(a,()=>n.tHtml("ADMIN_NEXT.RESET.NEW_PASSWORD_FOR",{username:r(A)})),m(e,t)};N(le,e=>{r(K)?e(de):e(me,-1)})}o(j),o(O);var U=d(O,2),F=s(U);{var ve=e=>{var t=Ve(),a=s(t,!0);o(t),p(i=>_(a,i),[()=>n.t("ADMIN_NEXT.RESET.THIS_RESET_LINK_IS_MISSING_REQUIRED")]),m(e,t)},_e=e=>{var t=Je(),a=s(t);Ke(a,{id:"password",label:"New password",get policy(){return z.current},get disabled(){return r(c)},get invalid(){return r(M)},invalidMessage:"Password does not meet the required policy",get value(){return r(u)},set value(l){v(u,l,!0)}});var i=d(a,2),C=s(i),ce=s(C,!0);o(C);var b=d(C,2);Xe(b);var fe=d(b,2);{var pe=l=>{var R=qe(),I=s(R,!0);o(R),p(G=>_(I,G),[()=>n.t("ADMIN_NEXT.RESET.PASSWORDS_DO_NOT_MATCH")]),m(l,R)};N(fe,l=>{r(h)&&l(pe)})}o(i);var Ee=d(i,2);Le(Ee,{type:"submit",class:"w-full",get disabled(){return r(c)},children:(l,R)=>{var I=q(),G=w(I);{var ge=f=>{var x=Qe(),D=w(x);Fe(D,{size:15,class:"animate-spin"});var xe=d(D);p(Se=>_(xe,` ${Se??""}`),[()=>n.t("ADMIN_NEXT.RESET.RESETTING")]),m(f,x)},be=f=>{var x=Ye(),D=w(x);He(D,{size:15}),we(),m(f,x)};N(G,f=>{r(c)?f(ge):f(be,-1)})}m(l,I)},$$slots:{default:!0}}),o(t),p(l=>{_(ce,l),ke(b,1,`flex h-9 w-full rounded-md border bg-transparent px-3 py-1 text-sm shadow-sm transition-all focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring
|
|
${r(h)?"border-red-500 ring-1 ring-red-500/30 animate-[shake_0.3s_ease-in-out]":"border-input"}`),b.disabled=r(c)},[()=>n.t("ADMIN_NEXT.RESET.CONFIRM_PASSWORD")]),Me("submit",t,te),Ce(b,()=>r(y),l=>v(y,l)),m(e,t)};N(F,e=>{r(K)?e(ve):e(_e,-1)})}var H=d(F,2),L=s(H),V=s(L);ze(V,{name:"arrow-back",size:12});var ue=d(V);o(L),o(H),o(U),o($),o(P),p((e,t,a)=>{Q(g,"aria-label",e),_(ne,t),Q(L,"href",`${Y??""}/login`),_(ue,` ${a??""}`)},[()=>n.t("ADMIN_NEXT.TOGGLE_DARK_MODE"),()=>n.t("ADMIN_NEXT.RESET.RESET_PASSWORD"),()=>n.t("ADMIN_NEXT.RESET.BACK_TO_SIGN_IN")]),ye("click",g,()=>Z.toggleColorMode()),m(ee,P),he()}Ae(["click"]);export{br as component};
|