PageSourceSearch

https://daur.onrender.com/assets/AdminAuthPage-CwfkwN8N.js

js daur.onrender.com collected 2026-10-03 11:40:37 UTC 4,095 bytes, 1 lines download raw bytes

1import{r as e}from"./rolldown-runtime-DwynqlJ6.js";import{n as t,t as a}from"./jsx-runtime-BIaHihzm.js";import{t as s}from"./shield-check-BmovwpNs.js";import{Ct as n,_t as r,kt as l,ot as i}from"./index-D_oUlhJ0.js";var o=e(t(),1),c=a();function d(){const e=l(),{setUser:t}=r(),[a,d]=(0,o.useState)("login"),[u,m]=(0,o.useState)("request"),[p,x]=(0,o.useState)(""),[f,b]=(0,o.useState)(""),[h,y]=(0,o.useState)(""),[g,j]=(0,o.useState)(""),[v,N]=(0,o.useState)(!1),[w,S]=(0,o.useState)(null),[k,q]=(0,o.useState)(null);return(0,c.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 px-4",children:(0,c.jsxs)("div",{className:"w-full max-w-sm bg-white border border-gray-100 rounded-2xl p-8",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-2 text-gray-500",children:[(0,c.jsx)(s,{size:16}),(0,c.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-widest",children:"Admin access"})]}),(0,c.jsx)("h1",{className:"font-serif text-2xl mb-6",children:"setup"===a?"Create the first admin account":"Admin sign in"}),"request"===u?(0,c.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),N(!0),S(null),q(null);try{const e="setup"===a?"/admin/setup/request":"/admin/login/request-otp",t="setup"===a?{email:p,fullName:f,setupKey:h}:{email:p},s=await fetch(`${n}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await s.json().catch(()=>({}));if(!s.ok)return void S(r.error||"Could not send code");q("setup"===a?"Verification code sent to that email.":"If that's an admin account, a code has been sent."),m("verify")}finally{N(!1)}},className:"space-y-4",children:[(0,c.jsx)("input",{type:"email",required:!0,value:p,onChange:e=>x(e.target.value),placeholder:"Email",className:"w-full border-b border-gray-200 py-2 text-sm focus:border-black outline-none"}),"setup"===a&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("input",{type:"text",required:!0,value:f,onChange:e=>b(e.target.value),placeholder:"Full name",className:"w-full border-b border-gray-200 py-2 text-sm focus:border-black outline-none"}),(0,c.jsx)("input",{type:"password",required:!0,value:h,onChange:e=>y(e.target.value),placeholder:"ADMIN_SETUP_KEY (server env var)",className:"w-full border-b border-gray-200 py-2 text-sm focus:border-black outline-none"})]}),w&&(0,c.jsx)("p",{className:"text-xs text-red-600",children:w}),(0,c.jsxs)("button",{type:"submit",disabled:v,className:"w-full bg-black text-white text-[10px] font-bold uppercase tracking-widest py-3 rounded-full disabled:opacity-40 flex items-center justify-center gap-2",children:[v&&(0,c.jsx)(i,{size:14,className:"animate-spin"})," Send code"]})]}):(0,c.jsxs)("form",{onSubmit:async s=>{s.preventDefault(),N(!0),S(null);try{const s=await fetch(`${n}${"setup"===a?"/admin/setup/verify":"/admin/login/verify-otp"}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:p,code:g})}),r=await s.json().catch(()=>({}));if(!s.ok)return void S(r.error||"Invalid or expired code");t(r.user,r.token),e("/admin")}finally{N(!1)}},className:"space-y-4",children:[k&&(0,c.jsx)("p",{className:"text-xs text-green-700",children:k}),(0,c.jsx)("input",{type:"text",required:!0,value:g,onChange:e=>j(e.target.value),placeholder:"6-digit code",maxLength:6,className:"w-full border-b border-gray-200 py-2 text-sm focus:border-black outline-none tracking-[0.3em]"}),w&&(0,c.jsx)("p",{className:"text-xs text-red-600",children:w}),(0,c.jsxs)("button",{type:"submit",disabled:v,className:"w-full bg-black text-white text-[10px] font-bold uppercase tracking-widest py-3 rounded-full disabled:opacity-40 flex items-center justify-center gap-2",children:[v&&(0,c.jsx)(i,{size:14,className:"animate-spin"})," Verify & continue"]})]}),(0,c.jsx)("button",{onClick:()=>{d("login"===a?"setup":"login"),m("request"),S(null),q(null)},className:"w-full text-center text-[10px] font-bold uppercase tracking-widest text-gray-400 hover:text-black mt-6",children:"login"===a?"Setting up the first admin account?":"Already have an admin account? Sign in"})]})})}export{d 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.