PageSourceSearch

https://lincon-draft-studio.lovable.app/assets/auth-D9jTnOxM.js

js lincon-draft-studio.lovable.app collected 2026-10-03 03:36:16 UTC 3,984 bytes, 1 lines download raw bytes

1import{a as E,g as S,r as a,s as o,j as e}from"./index-D1F-GEOk.js";function C(){const l=E(),h=S(),[n,x]=a.useState("signin"),[c,p]=a.useState(""),[m,b]=a.useState(""),[w,y]=a.useState(!1),[j,d]=a.useState(null),[v,i]=a.useState(null),[N,u]=a.useState(!1);async function g(s){const{data:t,error:r}=await o.from("user_roles").select("role").eq("user_id",s);return r?!1:(t??[]).some(f=>f.role==="admin")}a.useEffect(()=>{let s=!1;return o.auth.getSession().then(async({data:t})=>{if(s||!t.session)return;const r=await g(t.session.user.id);s||(r?l({to:"/admin/blog"}):u(!0))}),()=>{s=!0}},[l]);async function k(s){s.preventDefault(),y(!0),d(null),i(null);try{if(n==="forgot"){const{error:t}=await o.auth.resetPasswordForEmail(c,{redirectTo:`${window.location.origin}/reset-password`});if(t)throw t;i("Check je e-mail voor de reset-link.")}else if(n==="signin"){const{data:t,error:r}=await o.auth.signInWithPassword({email:c,password:m});if(r)throw r;if(!(t.user?await g(t.user.id):!1)){u(!0);return}await h.invalidate(),l({to:"/admin/blog"})}else{const{data:t,error:r}=await o.auth.signUp({email:c,password:m,options:{emailRedirectTo:`${window.location.origin}/admin/blog`}});if(r)throw r;if(t.session){if(!(t.user?await g(t.user.id):!1)){u(!0);return}await h.invalidate(),l({to:"/admin/blog"})}else i("Account aangemaakt. Bevestig je e-mail om in te loggen.")}}catch(t){d(t instanceof Error?t.message:"Er ging iets mis")}finally{y(!1)}}return e.jsx("section",{className:"min-h-[70vh] flex items-center justify-center bg-white px-6 py-24",children:e.jsx("div",{className:"w-full max-w-md rounded-2xl border border-border bg-white p-8 shadow-[0_10px_36px_rgba(0,0,0,0.08)]",children:N?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"font-display text-2xl font-bold",children:"Geen beheerdersrechten"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Je bent ingelogd, maar dit account heeft geen toegang tot het blogbeheer. Vraag een beheerder om je account rechten te geven, of log uit om met een ander account in te loggen."}),e.jsx("button",{type:"button",onClick:async()=>{await o.auth.signOut(),u(!1),p(""),b("")},className:"w-full rounded-full bg-primary text-white px-5 py-2.5 font-medium hover:bg-primary/90",children:"Uitloggen"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"font-display text-3xl font-bold mb-1",children:n==="signin"?"Inloggen":n==="signup"?"Account aanmaken":"Wachtwoord vergeten"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Blog beheer voor Lincon"}),e.jsxs("form",{onSubmit:k,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1 font-mono",children:"E-mail"}),e.jsx("input",{type:"email",required:!0,value:c,onChange:s=>p(s.target.value),className:"w-full rounded-lg border border-border px-3 py-2"})]}),n!=="forgot"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1 font-mono",children:"Wachtwoord"}),e.jsx("input",{type:"password",required:!0,minLength:6,value:m,onChange:s=>b(s.target.value),className:"w-full rounded-lg border border-border px-3 py-2"}),n==="signin"&&e.jsx("button",{type:"button",onClick:()=>{x("forgot"),d(null),i(null)},className:"mt-2 text-xs text-primary hover:underline",children:"Wachtwoord vergeten?"})]}),j&&e.jsx("p",{className:"text-sm text-red-600",children:j}),v&&e.jsx("p",{className:"text-sm text-primary",children:v}),e.jsx("button",{type:"submit",disabled:w,className:"w-full rounded-full bg-primary text-white px-5 py-2.5 font-medium hover:bg-primary/90 disabled:opacity-60",children:w?"Bezig...":n==="signin"?"Inloggen":n==="signup"?"Registreren":"Reset-link versturen"})]}),e.jsx("button",{onClick:()=>{x(n==="forgot"?"signin":n==="signin"?"signup":"signin"),d(null),i(null)},className:"mt-4 text-sm text-primary hover:underline",children:n==="forgot"?"Terug naar inloggen":n==="signin"?"Nog geen account? Registreer":"Al een account? Log in"})]})})})}export{C 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.