PageSourceSearch

https://n71.ai/assets/Auth-DksjztAO.js

js n71.ai collected 2026-10-05 12:17:33 UTC 11,979 bytes, 2 lines download raw bytes

1import{j as e}from"./ui-vendor-CBbdTawN.js";import{h as t,r as s,i as a}from"./react-vendor-DQSFk_7t.js";import{u as n,m as i,c as r,s as o,a as l}from"./index-DNEY-jN9.js";import{L as c}from"./loader-circle-BfESpXus.js";import"./supabase-NZ2Vt4Mp.js";import"./chart-vendor-Dq0yAQdW.js";import"./form-vendor-CzIjS8Un.js";const d=()=>{const[d]=t(),[u,m]=s.useState("login"),[x,h]=s.useState(""),[p,f]=s.useState(""),[b,g]=s.useState(!1),[y,v]=s.useState(!1),[j,w]=s.useState(null),[N,k]=s.useState(!1),[C,S]=s.useState(!1),_=a(),{user:R}=n(),[L,I]=s.useState(null),A="login"===u;s.useEffect(()=>{const e=d.get("email"),t=d.get("mode"),s=d.get("redirect"),a=d.get("workspace");e&&h(decodeURIComponent(e)),"signup"===t?m("signup"):"forgot"===t&&m("forgot"),a&&I(decodeURIComponent(a)),s&&sessionStorage.setItem("postAuthRedirect",decodeURIComponent(s))},[d,_]),s.useEffect(()=>{if(!R)return;if(sessionStorage.getItem("pending_oauth"))return void _("/process-oauth");const e=sessionStorage.getItem("postAuthRedirect");if(e)return sessionStorage.removeItem("postAuthRedirect"),void _(e);_("/context/dashboard")},[R,_]);return e.jsxs("div",{className:"min-h-screen bg-[#fafaf9] flex items-center justify-center relative",children:[e.jsx("header",{className:"absolute top-0 left-0 right-0 p-6",children:e.jsx(i.button,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.8,delay:.2},onClick:()=>_("/"),className:"text-sm font-semibold text-neutral-400 hover:text-neutral-600 tracking-widest transition-colors",children:"N71"})}),e.jsxs(i.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.5},className:"w-full max-w-sm px-6",children:[e.jsxs("div",{className:"text-center mb-10",children:[L&&"forgot"!==u&&e.jsx(i.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-violet-50 border border-violet-200 mb-4",children:e.jsxs("span",{className:"text-xs font-medium text-violet-700",children:["Joining ",L]})}),e.jsx("h1",{className:"text-2xl font-bold text-neutral-900 mb-2",children:"forgot"===u?"Reset your password":A?"Welcome back":"Create your account"}),e.jsx("p",{className:"text-sm text-neutral-500",children:"forgot"===u?"Enter your email and we'll send you a reset link":A?L?"Sign in to join the workspace":"Sign in to continue":L?"Create an account to join":"Get started with N71"})]}),C&&e.jsx(i.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-6 rounded-xl border border-amber-200 bg-amber-50 p-5",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"text-xl shrink-0",children:"⏳"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-amber-900 mb-1",children:"Rate limit reached"}),e.jsx("p",{className:"text-sm text-amber-700",children:"Too many attempts were made. The system limits how many emails can be sent per hour."}),e.jsxs("p",{className:"text-sm text-amber-700 mt-2",children:["Please wait ",e.jsx("strong",{children:"about an hour"}),", then come back and try again."]}),e.jsx("button",{type:"button",onClick:()=>S(!1),className:"mt-3 text-xs text-amber-800 hover:text-amber-950 underline underline-offset-2 transition-colors",children:"Try again now"})]})]})}),j&&"login"===u&&e.jsx(i.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},className:"mb-6 p-4 rounded-xl bg-amber-50 border border-amber-200",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-500 mt-0.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-amber-900",children:"Email not confirmed yet"}),e.jsxs("p",{className:"text-xs text-amber-700",children:["We sent a confirmation link to ",e.jsx("span",{className:"font-medium",children:j})," when you signed up. Please check your inbox (and spam folder) and click the link to activate your account."]}),e.jsxs("button",{type:"button",onClick:async()=>{var e;if(j){k(!0);try{const{error:t}=await o.auth.resend({type:"signup",email:j,options:{emailRedirectTo:`${window.location.origin}/n71`}});if(t){if(429===t.status||(null==(e=t.message)?void 0:e.toLowerCase().includes("rate limit")))return void S(!0);throw t}l.success("Confirmation email sent! Check your inbox.")}catch(t){l.error(t.message||"Failed to resend confirmation email")}finally{k(!1)}}},disabled:N,className:r("text-xs font-medium text-amber-800 hover:text-amber-950 underline underline-offset-2 transition-colors","disabled:opacity-50 disabled:cursor-not-allowed","flex items-center gap-1.5"),children:[N&&e.jsx(c,{className:"w-3 h-3 animate-spin"}),"Resend confirmation email"]})]})]})}),"forgot"===u&&y?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-green-50 mb-2",children:e.jsx("svg",{className:"w-6 h-6 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}),e.jsxs("p",{className:"text-sm text-neutral-600",children:["We've sent a password reset link to ",e.jsx("span",{className:"font-medium text-neutral-900",children:x}),". Check your inbox and click the link to set a new password."]}),e.jsxs("p",{className:"text-xs text-neutral-400",children:["Didn't receive it? Check your spam folder or"," ",e.jsx("button",{type:"button",onClick:()=>v(!1),className:"text-violet-600 hover:text-violet-700 underline",children:"try again"})]}),e.jsx("button",{type:"button",onClick:()=>{m("login"),v(!1)},className:"text-sm text-neutral-400 hover:text-neutral-600 transition-colors mt-4",children:"Back to sign in"})]}):"forgot"===u?e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:async e=>{var t;if(e.preventDefault(),x.trim()){g(!0);try{const{error:e}=await o.auth.resetPasswordForEmail(x,{redirectTo:`${window.location.origin}/reset-password`});if(e){if(429===e.status||(null==(t=e.message)?void 0:t.toLowerCase().includes("rate limit")))return void S(!0);throw e}v(!0),l.success("Check your email for a password reset link")}catch(s){l.error(s.message||"Failed to send reset email")}finally{g(!1)}}else l.error("Please enter your email address")},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-neutral-400 mb-1.5 block",children:"Email"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:x,onChange:e=>h(e.target.value),required:!0,disabled:b,autoFocus:!0,className:r("w-full px-4 py-3 rounded-xl border border-neutral-200 bg-white","text-sm text-neutral-900 placeholder:text-neutral-400","focus:outline-none focus:ring-2 focus:ring-violet-200 focus:border-violet-300","transition-all duration-200 disabled:opacity-50")})]}),e.jsxs("button",{type:"submit",disabled:b,className:r("w-full px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200","bg-neutral-900 text-white hover:bg-neutral-800","disabled:opacity-50 disabled:cursor-not-allowed","flex items-center justify-center gap-2 mt-2"),children:[b&&e.jsx(c,{className:"w-4 h-4 animate-spin"}),"Send reset link"]})]}),e.jsx("div",{className:"mt-8 text-center",children:e.jsx("button",{type:"button",onClick:()=>m("login"),disabled:b,className:"text-sm text-neutral-400 hover:text-neutral-600 transition-colors",children:"Back to sign in"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:async e=>{var t,s;e.preventDefault(),g(!0);try{if(A){const{error:e}=await o.auth.signInWithPassword({email:x,password:p});if(e)throw e;l.success("Signed in");if(sessionStorage.getItem("pending_oauth"))return void _("/process-oauth");const s=sessionStorage.getItem("postAuthRedirect");if(s)return sessionStorage.removeItem("postAuthRedirect"),void _(s);const{data:a}=await o.auth.getUser(),n=null==a?void 0:a.user;let i=!1;try{const e=!0===(null==(t=null==n?void 0:n.user_metadata)?void 0:t.has_seen_onboarding);let s=!1;if(n){const{data:e}=await o.from("person_identities").select("person_id").eq("provider_user_id",n.id).in("provider",["supabase_auth","auth"]).eq("active",!0),t=Array.from(new Set((e||[]).map(e=>e.person_id)));if(t.length>0){const{count:e}=await o.from("workspace_members").select("id",{count:"exact",head:!0}).in("person_id",t);s=(e??0)>0}}e||s||(i=!0,await o.auth.updateUser({data:{has_seen_onboarding:!0}}))}catch{}if(i)return void _("/onboarding");_("/context/dashboard")}else{const e=sessionStorage.getItem("postAuthRedirect"),t=e?`${window.location.origin}${e}`:`${window.location.origin}/n71`,{error:a}=await o.auth.signUp({email:x,password:p,options:{emailRedirectTo:t}});if(a){if(429===a.status||(null==(s=a.message)?void 0:s.toLowerCase().includes("rate limit")))return void S(!0);throw a}e?l.success("Account created! Check your email to confirm and complete the invite."):l.success("Account created. Check your email to confirm."),m("login")}}catch(a){const e=(a.message||"").toLowerCase();e.includes("email not confirmed")||e.includes("email address is not confirmed")?w(x):l.error(a.message||"An error occurred")}finally{g(!1)}},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-neutral-400 mb-1.5 block",children:"Email"}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:x,onChange:e=>h(e.target.value),required:!0,disabled:b,className:r("w-full px-4 py-3 rounded-xl border border-neutral-200 bg-white","text-sm text-neutral-900 placeholder:text-neutral-400","focus:outline-none focus:ring-2 focus:ring-violet-200 focus:border-violet-300","transition-all duration-200 disabled:opacity-50")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium uppercase tracking-wider text-neutral-400 mb-1.5 block",children:"Password"}),e.jsx("input",{type:"password",placeholder:"••••••••",value:p,onChange:e=>f(e.target.value),required:!0,disabled:b,minLength:6,className:r("w-full px-4 py-3 rounded-xl border border-neutral-200 bg-white","text-sm text-neutral-900 placeholder:text-neutral-400","focus:outline-none focus:ring-2 focus:ring-violet-200 focus:border-violet-300","transition-all duration-200 disabled:opacity-50")})]}),A&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>{m("forgot"),w(null)},className:"text-xs text-neutral-400 hover:text-violet-600 transition-colors",children:"Forgot password?"})}),e.jsxs("button",{type:"submit",disabled:b,className:r("w-full px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200","bg-neutral-900 text-white hover:bg-neutral-800","disabled:opacity-50 disabled:cursor-not-allowed","flex items-center justify-center gap-2 mt-2"),children:[b&&e.jsx(c,{className:"w-4 h-4 animate-spin"}),A?"Sign in":"Create account"]})]}),e.jsx("div",{className:"mt-8 text-center",children:A?e.jsx("button",{type:"button",onClick:()=>{m("signup"),w(null)},disabled:b,className:"text-sm text-neutral-400 hover:text-neutral-600 transition-colors",children:"Don't have an account? Sign up"}):e.jsx("button",{type:"button",onClick:()=>{m("login"),w(null)},disabled:b,className:"text-sm text-neutral-400 hover:text-neutral-600 transition-colors",children:"Already have an account? Sign in"})})]})]}),e.jsx("footer",{className:"absolute bottom-0 left-0 right-0 p-6",children:e.jsx("div",{className:"flex items-center justify-center gap-6 text-xs text-neutral-400",children:e.jsx("span",{children:"© 2026 N71"})})})]})};export{d as default};
2//# sourceMappingURL=Auth-DksjztAO.js.map

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.