PageSourceSearch

https://tbuddy.app/assets/forgot-password-cv7whEek.js

js tbuddy.app collected 2026-10-02 01:16:08 UTC 3,801 bytes, 1 lines download raw bytes

1import{e as C,r,j as e,A as S,g,h as a,s as m}from"./index-BOoZFuWa.js";import{f as x,c as E}from"./friendly-error-_aO9xRIl.js";function z(){const h=C(),[d,y]=r.useState("email"),[o,b]=r.useState(""),[p,j]=r.useState(""),[n,N]=r.useState(""),[i,c]=r.useState(!1),[l,f]=r.useState(0);r.useEffect(()=>{if(l<=0)return;const t=setTimeout(()=>f(s=>s-1),1e3);return()=>clearTimeout(t)},[l]);async function w(t){if(t?.preventDefault(),!o.trim())return a.error("Enter your email first.");c(!0);const{error:s}=await m.auth.resetPasswordForEmail(o.trim().toLowerCase(),{redirectTo:window.location.origin+"/forgot-password"});if(c(!1),s)return a.error(x(s.message));a.success("We sent a verification code to your email."),y("verify"),f(45)}async function v(t){t.preventDefault();const s=E(p);if(s.length!==6&&s.length!==8)return a.error("Enter the code from your email.");if(n.length<8||!/[A-Za-z]/.test(n)||!/[0-9]/.test(n))return a.error("New password needs 8+ characters with letters and numbers.");c(!0);let{error:u}=await m.auth.verifyOtp({email:o.trim().toLowerCase(),token:s,type:"recovery"});if(u||(u=(await m.auth.updateUser({password:n})).error),c(!1),u)return a.error(x(u.message));a.success("Password updated. Please sign in."),await m.auth.signOut(),h({to:"/login",replace:!0})}return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"mx-auto max-w-md min-h-screen flex flex-col px-6 pt-6 pb-10 safe-top safe-bottom",children:[e.jsxs("button",{type:"button",onClick:()=>{typeof window<"u"&&window.history.length>1?window.history.back():typeof window<"u"&&window.location.assign("/login")},className:"inline-flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(S,{className:"size-4"})," Back"]}),e.jsx("h1",{className:"mt-8 text-3xl font-semibold font-display",children:d==="email"?"Forgot password":"Set new password"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:d==="email"?"Enter your email and we'll send a reset code.":e.jsxs(e.Fragment,{children:["We sent a code to ",e.jsx("strong",{children:o}),". Enter it below with your new password."]})}),d==="email"&&e.jsxs("form",{onSubmit:w,className:"mt-6 space-y-3",children:[e.jsx("input",{required:!0,type:"email",placeholder:"[email protected]",value:o,onChange:t=>b(t.target.value),className:"w-full rounded-xl bg-card border border-input px-4 py-3.5 outline-none focus:ring-2 focus:ring-ring"}),e.jsxs("button",{disabled:i,className:"w-full rounded-2xl bg-gradient-warm text-primary-foreground font-semibold py-3.5 shadow-card disabled:opacity-60 inline-flex items-center justify-center gap-2",children:[i&&e.jsx(g,{className:"size-4 animate-spin"})," Send reset code"]})]}),d==="verify"&&e.jsxs("form",{onSubmit:v,className:"mt-6 space-y-3",children:[e.jsx("input",{required:!0,inputMode:"numeric",pattern:"[0-9]{6,8}",maxLength:8,placeholder:"123456",value:p,onChange:t=>j(t.target.value.replace(/\D/g,"")),className:"w-full rounded-xl bg-card border border-input px-4 py-3.5 text-center text-2xl tracking-[0.4em] font-semibold"}),e.jsx("input",{required:!0,type:"password",minLength:8,placeholder:"New password (letters + numbers)",value:n,onChange:t=>N(t.target.value),className:"w-full rounded-xl bg-card border border-input px-4 py-3.5 outline-none focus:ring-2 focus:ring-ring"}),e.jsxs("button",{disabled:i,className:"w-full rounded-2xl bg-gradient-warm text-primary-foreground font-semibold py-3.5 shadow-card disabled:opacity-60 inline-flex items-center justify-center gap-2",children:[i&&e.jsx(g,{className:"size-4 animate-spin"})," Update password"]}),e.jsx("button",{type:"button",disabled:i||l>0,onClick:()=>w(),className:"w-full text-sm text-primary py-2 disabled:opacity-50",children:l>0?`Resend in ${l}s`:"Resend code"})]})]})})}export{z as component};

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.