PageSourceSearch

https://joyahealth.com/assets/LinkExpired-DKU5AyX9.js

js joyahealth.com collected 2026-10-07 13:08:35 UTC 9,883 bytes, 1 lines download raw bytes

1import{a as i,j as e}from"./vendor-query-CR-VCSTz.js";import{E as G,S as U,J as z,L as D,I as A,T as H,B as K,F as V,G as X,D as Q}from"./index-BrkMe9fl.js";import{c as Z,L as E}from"./vendor-react-CcMhIRHi.js";import{G as ee,c as M,f as te,ah as se,a as P,A as ie}from"./vendor-icons-Bkm9ycWJ.js";import"./vendor-charts-CBhuxwPC.js";import"./vendor-supabase-Dp23wbUo.js";import"./vendor-forms-C0xMzmLW.js";const k=60,L=l=>`joya:magic-link-sent:${l.toLowerCase()}`;function ce(){const[l]=Z(),x=l.get("error_code")??l.get("error"),c=l.get("error_description"),w=(l.get("email")??"").trim(),[u,W]=i.useState(w),[p,$]=i.useState(""),[y,_]=i.useState(null),[b,v]=i.useState(null),[r,a]=i.useState({kind:"idle"}),[n,h]=i.useState(0),[R,f]=i.useState(""),[F,J]=i.useState("loading"),T=i.useRef(null),j=r.kind==="sending",d=(u??"").trim(),B=(p??"").trim(),o=d.length>0&&d.toLowerCase()===B.toLowerCase(),N=R.trim().length>0,C=i.useMemo(()=>{const t=(x??"").toLowerCase(),s=(c??"").toLowerCase();return t.includes("expired")||t==="otp_expired"||s.includes("expired")?{kind:"expired",title:"This sign-in link has expired",summary:"Links stay valid for only a few minutes. Request a fresh one below and open it right away.",steps:["Confirm your email address is correct.","Tap “Email me a new link” to send a fresh link.","Open the new email within 5 minutes, on this same device and browser."]}:t.includes("used")||t.includes("consumed")||s.includes("already")?{kind:"used",title:"This sign-in link was already used",summary:"For your security, each link works only once — even a preview scan by your email provider can consume it.",steps:["Request a new link below.","Open it directly from the email (don’t forward or preview it).","If your inbox auto-scans links, copy the link and paste it into your browser instead."]}:t.includes("rate")||t.includes("too_many")||t.includes("blocked")||s.includes("rate")||s.includes("too many")?{kind:"blocked",title:"Too many sign-in attempts",summary:"We’ve temporarily paused new links for this email to protect your account.",steps:["Wait for the countdown below to finish.","Check your inbox and spam folder — a valid link may already be waiting.","If none arrive, try again after the cooldown ends."]}:t.includes("access_denied")||t.includes("invalid")||t?{kind:"invalid",title:"This sign-in link isn’t valid here",summary:"The link may have been opened in a different browser, device, or private window than the one that requested it.",steps:["Return to the device and browser where you first requested the link.","Or request a new link below and open it in this browser.","Disable “open links in app” settings if your email client is intercepting the URL."]}:{kind:"unknown",title:"This sign-in link is no longer valid",summary:c??"It may have expired, already been used, or been opened in a different browser.",steps:["Enter your email below.","Request a fresh sign-in link.","Open the new link on this device within a few minutes."]}},[x,c]);i.useEffect(()=>{!x&&!c&&!w||G({email:w||"[email protected]",outcome:"link_invalid",source:"link_expired_page",error_code:x,error_description:c})},[]),i.useEffect(()=>{if(!u){h(0);return}try{const t=sessionStorage.getItem(L(u)),s=t?parseInt(t,10):0,m=s?Math.max(0,k-Math.floor((Date.now()-s)/1e3)):0;h(m)}catch{}},[u]),i.useEffect(()=>{if(n<=0)return;const t=window.setInterval(()=>{h(s=>s<=1?0:s-1)},1e3);return()=>window.clearInterval(t)},[n]);async function Y(t){var I,q;t.preventDefault(),_(null),v(null);const s=V.safeParse({email:d});if(!s.success){_(((I=s.error.issues[0])==null?void 0:I.message)??"Enter a valid email.");return}if(!o){v("The two email addresses don't match.");return}if(!N){a({kind:"error",email:s.data.email,message:"Complete the security check before requesting a new link."});return}if(n>0){a({kind:"rate_limited",email:s.data.email,waitSeconds:n,message:`Please wait ${n}s before requesting another link.`});return}a({kind:"sending",email:s.data.email});const{error:m}=await X(s.data.email,R,"link_expired_page");if(f(""),(q=T.current)==null||q.reset(),m){const O=m.toLowerCase(),S=m.match(/after\s+(\d+)\s+seconds?/i);if(S||O.includes("rate limit")||O.includes("too many")){const g=S?parseInt(S[1],10):k;h(g);try{sessionStorage.setItem(L(s.data.email),String(Date.now()-(k-g)*1e3))}catch{}a({kind:"rate_limited",email:s.data.email,waitSeconds:g,message:`Too many requests for this email. Please wait ${g}
1s — or check your inbox and spam folder for a link we've already sent.`});return}a({kind:"error",email:s.data.email,message:Q(m)});return}try{sessionStorage.setItem(L(s.data.email),String(Date.now()))}catch{}h(k),a({kind:"sent",email:s.data.email,at:Date.now()})}return e.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-background px-6 py-16",children:[e.jsx(U,{noindex:!0,title:"Sign-in link expired",description:"Your JOYA Wellness sign-in or password reset link has expired. Request a fresh magic link or reset email to securely access your account."}),e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(E,{to:"/","aria-label":"JOYA home",className:"inline-block",children:e.jsx(z,{className:"mx-auto h-14 w-auto"})}),e.jsx("h1",{className:"mt-6 font-display text-2xl text-foreground",children:C.title})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-3 text-sm text-foreground",children:[e.jsx(ee,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsx("p",{children:C.summary})]}),e.jsxs("div",{className:"rounded-md border border-border bg-muted/40 px-4 py-3 text-sm text-foreground",children:[e.jsx("p",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"How to recover"}),e.jsx("ol",{className:"ml-5 list-decimal space-y-1 text-sm",children:C.steps.map(t=>e.jsx("li",{children:t},t))})]}),e.jsxs("form",{onSubmit:Y,className:"space-y-4",noValidate:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"link-expired-email",children:"Email"}),e.jsx(A,{id:"link-expired-email",type:"email",autoComplete:"email",required:!0,value:u,onChange:t=>{W(t.target.value),r.kind!=="idle"&&r.kind!=="sending"&&a({kind:"idle"})},placeholder:"[email protected]","aria-invalid":!!y}),y&&e.jsx("p",{className:"text-xs text-destructive",children:y})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"link-expired-email-confirm",children:"Confirm email"}),e.jsx(A,{id:"link-expired-email-confirm",type:"email",autoComplete:"off",required:!0,value:p,onChange:t=>{$(t.target.value),v(null)},placeholder:"Retype your email","aria-invalid":!!b||p.length>0&&!o}),b?e.jsx("p",{className:"text-xs text-destructive",children:b}):p.length>0&&!o?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails don't match yet."}):o?e.jsxs("p",{className:"flex items-center gap-1 text-xs text-emerald-700",children:[e.jsx(M,{className:"h-3 w-3"})," Emails match"]}):null]}),r.kind==="sent"&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-3 text-sm text-foreground",children:[e.jsx(M,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"New sign-in link sent"}),e.jsxs("p",{className:"text-muted-foreground",children:["We emailed a fresh link to ",e.jsx("span",{className:"font-medium text-foreground",children:r.email}),". Open it in this browser within a few minutes. Check spam if it doesn't arrive."]})]})]}),r.kind==="rate_limited"&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-3 text-sm text-foreground",children:[e.jsx(te,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Please wait before retrying"}),e.jsx("p",{className:"text-muted-foreground",children:r.message})]})]}),r.kind==="error"&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-3 text-sm text-foreground",children:[e.jsx(se,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"We couldn't send the link"}),e.jsx("p",{className:"text-muted-foreground",children:r.message})]})]}),r.kind==="sending"&&e.jsxs("p",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(P,{className:"h-4 w-4 animate-spin"})," Sending a new link to ",r.email,"…"]}),e.jsx(H,{ref:T,onToken:f,onExpire:()=>f(""),onError:()=>f(""),onStatusChange:J}),e.jsxs(K,{type:"submit",className:"w-full",size:"lg",disabled:j||n>0||!o||!N,children:[j?e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}):null,n>0?`Resend in ${n}s`:r.kind==="sent"?"Send another link":"Email me a new link",n===0&&!j?e.jsx(ie,{className:"ml-2 h-4 w-4"}):null]}),!o&&d.length>0&&e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"Confirm your email above to enable the button."}),o&&!N&&F!=="error"&&e.jsx("p",{className:"text-center text-xs text-muted-foreground",children:"Complete the security check to enable the button."})]}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Links keep getting used up by your email system?"," ",e.jsx(E,{to:`/auth/verify-code?purpose=login${d?`&email=${encodeURIComponent(d)}`:""}`,className:"font-medium text-foreground underline-offset-4 hover:underline",children:"Email me a code instead"})]}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:["Prefer to sign in with a password?"," ",e.jsx(E,{to:"/auth",className:"font-medium text-foreground underline-offset-4 hover:underline",children:"Back to sign in"})]})]})]})}export{ce as default};

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.