PageSourceSearch

https://gradethread.com/assets/reset-password-BshXfAXE.js

js gradethread.com collected 2026-10-10 01:46:14 UTC 6,377 bytes, 1 lines download raw bytes

1import{q as F,j as e,n as B,k as t,L as f}from"./vendor-react-CowE5YCj.js";import{k as D,u as V,b as A}from"./auth-CcWyxVus.js";import{P as T,T as H,a as U,c as W}from"./password-policy-D_P3zMQ2.js";import{c5 as M,c6 as b,t as w,x as j,y as g,v as y,u as P,w as k,g as L,cd as q}from"./index-BwzqfZRD.js";import{r as Y}from"./auth-error-DrjZhUfo.js";import{I as G}from"./input-CLuxJVgs.js";import{P as I,v as z}from"./validation-Chn9XLXp.js";import{L as C}from"./label-CGppZHlV.js";import{F as R}from"./form-feedback-pkrNDt8r.js";import{t as O}from"./toast-error-BDOwNR3J.js";import{S as J}from"./seo-Bc6Qy8zj.js";import"./vendor-query-VEVGS95H.js";import"./vendor-supabase-Baxrk5fR.js";import"./eye-off-Z5q9PGX6.js";import"./eye-CycfWzsj.js";import"./index-clxdtWr2.js";import"./circle-alert-O2pEuqlX.js";import"./friendly-error-BmcA0avy.js";const K=1e4;function fe(){const[i]=F();return i.has("token")||i.has("code")||i.has("token_hash")?e.jsx(X,{}):e.jsx(Q,{})}function Q(){const[i,m]=t.useState(""),[d,v]=t.useState(!1),[S,N]=t.useState(!1),[c,h]=t.useState(void 0),[a,l]=t.useState(null),[p,n]=t.useState(0);async function E(s){s.preventDefault();const r=z(i);if(h(r),r){document.getElementById("email")?.focus();return}if(W&&!a){q.error("Please complete the verification challenge.");return}v(!0);try{await A(i,a??void 0),N(!0)}catch(o){O(o,"Failed to send reset email"),l(null),n(x=>x+1)}finally{v(!1)}}return S?e.jsxs(w,{children:[e.jsxs(j,{className:"text-center",children:[e.jsx(g,{children:"Check your email"}),e.jsxs(y,{children:["We sent a password reset link to ",e.jsx("strong",{children:i}),"."]})]}),e.jsx(k,{className:"justify-center",children:e.jsx(f,{to:"/login",className:"text-sm text-brand-red-text hover:underline",children:"Back to sign in"})})]}):e.jsxs(w,{children:[e.jsx(J,{title:"Reset your password",noindex:!0}),e.jsxs(j,{className:"text-center",children:[e.jsx(g,{children:"Reset password"}),e.jsx(y,{children:"Enter your email and we'll send you a reset link."})]}),e.jsx(P,{children:e.jsxs("form",{onSubmit:E,className:"space-y-4",noValidate:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"email",children:"Email"}),e.jsx(G,{id:"email",type:"email",autoComplete:"email",placeholder:"[email protected]",value:i,onChange:s=>{m(s.target.value),c&&h(void 0)},required:!0,"aria-invalid":!!c,"aria-describedby":c?"email-error":void 0}),e.jsx(R,{id:"email-error",children:c})]}),e.jsx(H,{onVerify:l,onExpire:()=>l(null),resetSignal:p}),e.jsx(L,{type:"submit",className:"w-full",disabled:d,children:d?"Sending...":"Send reset link"})]})}),e.jsx(k,{className:"justify-center",children:e.jsx(f,{to:"/login",className:"text-sm text-muted-foreground hover:underline",children:"Back to sign in"})})]})}function X(){const i=B(),[m]=F(),[d,v]=t.useState(""),[S,N]=t.useState(""),[c,h]=t.useState(!1),[a,l]=t.useState({}),[p,n]=t.useState("checking");t.useEffect(()=>{const{url:s,changed:r}=M(window.location.href);r&&window.history.replaceState(window.history.state,"",s)},[]),t.useEffect(()=>{if(Y()){n("expired");return}let s=!0;const r=m.get("token_hash");if(r)return D(r,m.get("type")??"recovery").then(()=>{s&&n("ready")}).catch(()=>{s&&n("expired")}),()=>{s=!1};b.auth.getSession().then(({data:u})=>{s&&u.session&&n("ready")});const{data:o}=b.auth.onAuthStateChange((u,_)=>{(u==="PASSWORD_RECOVERY"||u==="SIGNED_IN"&&_)&&n("ready")}),x=window.setTimeout(()=>{n(u=>u==="checking"?"expired":u)},K);return()=>{s=!1,o.subscription.unsubscribe(),window.clearTimeout(x)}},[m]);async function E(s){if(s.preventDefault(),p!=="ready")return;const r=U(d),o={password:r.ok?void 0:r.reason??"Password does not meet the requirements",confirm:d!==S?"Passwords do not match":void 0};if(l(o),o.password||o.confirm){document.getElementById(o.password?"password":"confirm")?.focus();return}h(!0);try{await V(d),await b.auth.signOut({scope:"global"}).catch(()=>{}),q.success("Password updated. Please sign in with your new password."),i("/login",{replace:!0})}catch(x){O(x,"Failed to update password")}finally{h(!1)}}return p==="checking"?e.jsxs(w,{children:[e.jsxs(j,{className:"text-center",children:[e.jsx(g,{children:"Set new password"}),e.jsx(y,{children:"Verifying your reset link…"})]}),e.jsx(P,{className:"flex justify-center py-6",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})})]}):p==="expired"?e.jsxs(w,{children:[e.jsxs(j,{className:"text-center",children:[e.jsx(g,{children:"Reset link invali
1d or expired"}),e.jsx(y,{children:"This password reset link is no longer valid. Request a new one to try again."})]}),e.jsxs(k,{className:"justify-center gap-4",children:[e.jsx(f,{to:"/auth/reset-password",className:"text-sm text-brand-red-text hover:underline",children:"Request a new link"}),e.jsx(f,{to:"/login",className:"text-sm text-muted-foreground hover:underline",children:"Back to sign in"})]})]}):e.jsxs(w,{children:[e.jsxs(j,{className:"text-center",children:[e.jsx(g,{children:"Set new password"}),e.jsx(y,{children:"Enter your new password below."})]}),e.jsx(P,{children:e.jsxs("form",{onSubmit:E,className:"space-y-4",noValidate:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"password",children:"New password"}),e.jsx(I,{id:"password",showStrength:!0,autoComplete:"new-password",placeholder:T,value:d,onChange:s=>{v(s.target.value),a.password&&l(r=>({...r,password:void 0}))},required:!0,minLength:10,"aria-invalid":!!a.password,"aria-describedby":a.password?"password-error":"password-hint"}),e.jsx(R,{id:"password-error",children:a.password})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"confirm",children:"Confirm new password"}),e.jsx(I,{id:"confirm",autoComplete:"new-password",value:S,onChange:s=>{N(s.target.value),a.confirm&&l(r=>({...r,confirm:void 0}))},required:!0,minLength:10,"aria-invalid":!!a.confirm,"aria-describedby":a.confirm?"confirm-error":void 0}),e.jsx(R,{id:"confirm-error",children:a.confirm})]}),e.jsx("p",{id:"password-hint",className:"text-xs text-muted-foreground",children:T}),e.jsx(L,{type:"submit",className:"w-full",disabled:c,children:c?"Updating...":"Update password"})]})}),e.jsx(k,{className:"justify-center",children:e.jsx(f,{to:"/login",className:"text-sm text-muted-foreground hover:underline",children:"Back to sign in"})})]})}
1export{fe as ResetPasswordPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.