PageSourceSearch

https://blueroots-production.up.railway.app/assets/setup-password-page-Bn1lsGig.js

js blueroots-production.up.railway.app collected 2026-10-03 12:12:13 UTC 4,725 bytes, 1 lines download raw bytes

1import{j as s}from"./tanstack-raftEBQU.js";import{u as R,i as A,r as e}from"./react-vendor-DG9jHnNQ.js";import{bj as I,bm as U,p as B,s as D,t as G,ai as H,q as M,ah as f,i as w,ag as y,af as g,b0 as O}from"./index-CwEfLZlp.js";import{C as V}from"./circle-x-Cq33LyY0.js";import{C as W}from"./circle-check-BHqhkodH.js";import"./radix-B0zOOFBK.js";import"./charts-ycOWY838.js";import"./dnd-IADusAtS.js";function _(){const[,d]=R(),m=A(),{login:j}=I(),{toast:c}=U(),[N,b]=e.useState(""),[u,k]=e.useState(""),[v,P]=e.useState(""),[a,S]=e.useState(""),[i,C]=e.useState(""),[L,o]=e.useState(!0),[x,p]=e.useState(!1),[h,l]=e.useState(""),[E,F]=e.useState(!1);e.useEffect(()=>{const t=m.token||new URLSearchParams(window.location.hash.split("?")[1]||"").get("token")||"";if(!t){l("No setup token found. Please use the link from your invitation email."),o(!1);return}b(t),(async()=>{try{const r=await fetch(`/api/auth/setup-password/${t}`),n=await r.json();if(!r.ok||!n.valid){l(n.message||"Invalid or expired setup link."),o(!1);return}k(n.username),P(n.displayName),o(!1)}catch{l("Failed to validate setup link."),o(!1)}})()},[m.token]);const T=async t=>{if(t.preventDefault(),a.length<6){c({title:"Password too short",description:"Must be at least 6 characters",variant:"destructive"});return}if(a!==i){c({title:"Passwords don't match",variant:"destructive"});return}p(!0);try{const r=await O("POST","/api/auth/setup-password",{token:N,password:a});if(!r.ok){const q=await r.json();throw new Error(q.message||"Failed to set password")}const n=await r.json();F(!0),setTimeout(()=>{j(u,a),d("/")},1500)}catch(r){c({title:"Error",description:r.message,variant:"destructive"})}finally{p(!1)}};return s.jsx("div",{className:"min-h-screen flex items-center justify-center p-4",style:{background:"linear-gradient(135deg, #0b1020 0%, #1a1040 50%, #0b1020 100%)"},children:s.jsxs(B,{className:"w-full max-w-md border-sky-900/30 bg-[#13162a]/95 backdrop-blur",children:[s.jsxs(D,{className:"text-center space-y-2",children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:"Blueroots"}),s.jsx("div",{className:"text-xs text-sky-300/60",children:"A place where everything in your campaign universe is at your fingertips."}),s.jsxs(G,{className:"text-lg text-white pt-4 flex items-center justify-center gap-2",children:[s.jsx(H,{className:"h-5 w-5"})," Set Your Password"]})]}),s.jsx(M,{children:L?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(f,{className:"h-6 w-6 animate-spin text-sky-400"}),s.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:"Validating your invitation..."})]}):h?s.jsxs("div",{className:"flex flex-col items-center py-8 space-y-3",children:[s.jsx(V,{className:"h-10 w-10 text-red-400"}),s.jsx("p",{className:"text-sm text-red-300 text-center",children:h}),s.jsx(w,{variant:"outline",onClick:()=>d("/"),className:"mt-4",children:"Go to Login"})]}):E?s.jsxs("div",{className:"flex flex-col items-center py-8 space-y-3",children:[s.jsx(W,{className:"h-10 w-10 text-emerald-400"}),s.jsx("p",{className:"text-sm text-emerald-300",children:"Password set successfully. Logging you in..."})]}):s.jsxs("form",{onSubmit:T,className:"space-y-4",children:[s.jsxs("div",{className:"rounded-lg bg-sky-900/20 border border-sky-800/30 p-3 mb-4",children:[s.jsxs("p",{className:"text-xs text-sky-300/70",children:["Welcome, ",s.jsx("span",{className:"font-semibold text-sky-200",children:v})]}),s.jsxs("p",{className:"text-xs text-sky-300/50 mt-1",children:["Username: ",s.jsx("span",{className:"font-mono text-sky-200",children:u})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(y,{htmlFor:"password",className:"text-sky-200",children:"New Password"}),s.jsx(g,{id:"password",type:"password",value:a,onChange:t=>S(t.target.value),placeholder:"At least 6 characters",required:!0,minLength:6,className:"bg-[#0b1020] border-sky-900/40 text-white","data-testid":"input-setup-password"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(y,{htmlFor:"confirmPassword",className:"text-sky-200",children:"Confirm Password"}),s.jsx(g,{id:"confirmPassword",type:"password",value:i,onChange:t=>C(t.target.value),placeholder:"Re-enter your password",required:!0,minLength:6,className:"bg-[#0b1020] border-sky-900/40 text-white","data-testid":"input-setup-confirm"}),i&&a!==i&&s.jsx("p",{className:"text-xs text-red-400",children:"Passwords don't match"})]}),s.jsx(w,{type:"submit",className:"w-full bg-sky-700 hover:bg-sky-600",disabled:x||a.length<6||a!==i,"data-testid":"button-setup-submit",children:x?s.jsxs(s.Fragment,{children:[s.jsx(f,{className:"h-4 w-4 mr-2 animate-spin"})," Setting Password..."]}):"Set Password & Log In"})]})})]})})}export{_ 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.