PageSourceSearch

https://joinoriginhouse.com/assets/auth.confirm-Dx7KnrLh.js

js joinoriginhouse.com collected 2026-10-04 20:24:27 UTC 2,911 bytes, 1 lines download raw bytes

1import{T,am as E,r as i,j as e,U as f}from"./index-BuCKDUqr.js";function R(){const u=T(),{token_hash:m,type:h,redirect_to:n}=E.useSearch(),[t,r]=i.useState("verifying"),[c,a]=i.useState(null),[d,b]=i.useState(""),[g,k]=i.useState(""),[w,x]=i.useState(!1);i.useEffect(()=>{let s=!1;async function o(){const p=typeof window<"u"?window.location.hash:"",j=new URLSearchParams(p.startsWith("#")?p.slice(1):p),l=h??j.get("type")??void 0;if(!m){const{data:C}=await f.auth.getSession();if(s)return;if(C.session){if(l==="recovery"){r("ready");return}r("done");const P=n&&n.startsWith("/")?n:"/admin";setTimeout(()=>u({to:P}),600);return}r("error"),a("Missing confirmation token. Open the link from your email again.");return}if(!l){r("error"),a("Missing confirmation type. Open the link from your email again.");return}const{error:v}=await f.auth.verifyOtp({token_hash:m,type:l});if(s)return;if(v){r("error"),a(v.message);return}if(l==="recovery"){r("ready");return}r("done");const S=n&&n.startsWith("/")?n:"/admin";setTimeout(()=>u({to:S}),600)}return o(),()=>{s=!0}},[m,h,n,u]);async function N(s){if(s.preventDefault(),a(null),d.length<8){a("Password must be at least 8 characters.");return}if(d!==g){a("Passwords don't match.");return}x(!0);try{const{error:o}=await f.auth.updateUser({password:d});if(o)throw o;r("done"),a("Password updated. Redirecting."),setTimeout(()=>u({to:"/admin"}),600)}catch(o){a(o instanceof Error?o.message:"Something went wrong.")}finally{x(!1)}}const y="w-full border border-[var(--border)] bg-transparent px-4 py-3 text-[var(--ink)] focus:border-[var(--ink)] focus:outline-none";return e.jsx("main",{className:"min-h-screen bg-[var(--bg)] px-6 pt-32 md:pt-40",children:e.jsxs("div",{className:"mx-auto max-w-md",children:[e.jsxs("h1",{className:"font-serif text-3xl text-[var(--ink)] md:text-4xl",children:[t==="verifying"&&"Verifying.",t==="ready"&&"Set a new password.",t==="done"&&"All set.",t==="error"&&"Link issue."]}),t==="ready"&&e.jsxs("form",{onSubmit:N,className:"mt-10 space-y-4",children:[e.jsx("input",{type:"password",required:!0,minLength:8,autoComplete:"new-password",placeholder:"New password",value:d,onChange:s=>b(s.target.value),className:y}),e.jsx("input",{type:"password",required:!0,minLength:8,autoComplete:"new-password",placeholder:"Confirm new password",value:g,onChange:s=>k(s.target.value),className:y}),c&&e.jsx("p",{className:"text-sm text-[var(--ink)]",children:c}),e.jsx("button",{type:"submit",disabled:w,className:"w-full bg-[var(--ink)] px-6 py-3 text-sm font-medium text-[var(--bg)] disabled:opacity-50",children:w?"...":"Update password"})]}),(t==="verifying"||t==="done"||t==="error")&&c&&e.jsx("p",{className:"mt-6 text-sm text-[var(--ink-dim)]",children:c}),t==="error"&&e.jsx("button",{type:"button",onClick:()=>u({to:"/auth"}),className:"mt-6 text-xs text-[var(--ink-dim)] underline",children:"Back to sign in"})]})})}export{R 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.