PageSourceSearch

https://forzi.ai/assets/Auth-DpMKyBD1.js

js forzi.ai collected 2026-10-05 13:42:34 UTC 15,522 bytes, 1 lines download raw bytes

1import{y as ee,r as c,z as re,D as se,l as te,u as ae,E as a,v as u,J as K,j as e,q as oe,L as z,I as y,B as A,K as ie}from"./index-DZhdmuyI.js";import{F as ne}from"./ForziLogo-X5xDjhT1.js";import{L as v}from"./label-C6XqPx8a.js";import{r as le}from"./slsParticipant-DTThIXMC.js";import{m as q}from"./proxy-DP3iu0GK.js";import{E as P}from"./eye-off-f3bG64h4.js";import{E as L}from"./eye-DF8wEgDx.js";const we=()=>{const[s]=ee(),[_,G]=c.useState(""),[r,o]=c.useState(s.get("mode")||(s.get("ref")?"signup":"login")),[E,T]=c.useState(""),[N,O]=c.useState(""),[I,Q]=c.useState(()=>s.get("ref")||re()||""),[M]=c.useState(()=>s.get("cref")||se()||""),[k,n]=c.useState(!1),[m,S]=c.useState(!1),[X,C]=c.useState(!1),[F,U]=c.useState(null),[R,B]=c.useState(""),[D,b]=c.useState(!1),x=te(),{user:V,isAdmin:de,isSuperAdmin:ce,loading:W}=ae();c.useEffect(()=>{if(!W&&V&&!D&&r!=="reset_password"&&r!=="mfa_challenge"&&!s.get("token_hash")){const t=K()?"/review":"/app";x(s.get("redirect")||t,{replace:!0})}},[W,V,D,x,s,r]),c.useEffect(()=>{const t=s.get("claim_plan");t&&localStorage.setItem("forzi_claim_plan",t);const w=window.location.hash;if(w.includes("error=")){const p=new URLSearchParams(w.slice(1)),l=p.get("error_code")||"",d=(p.get("error_description")||"").replace(/\+/g," ");l==="otp_expired"?a.error("This link has expired. Please request a new password reset email."):l==="access_denied"?a.error(d||"Access denied. The link may be invalid or already used."):a.error(d||"Authentication error. Please try again."),o("forgot_password"),window.history.replaceState(null,"",window.location.pathname+window.location.search)}else if(s.get("token_hash")&&s.get("type")){const p=s.get("token_hash"),l=s.get("type");n(!0),u.auth.verifyOtp({token_hash:p,type:l}).then(async({data:d,error:j})=>{if(n(!1),j)a.error(j.message),o("login");else{if(d!=null&&d.session)await u.auth.setSession({access_token:d.session.access_token,refresh_token:d.session.refresh_token});else if(l==="recovery"||l==="invite"){a.error("Verification succeeded, but no session was returned. Please try logging in normally or requesting a new link."),o("login");return}l==="recovery"||l==="invite"?(a.success("Verified! Please set a new password."),o("reset_password")):(a.success("Successfully verified!"),x(K()?"/review":"/app/onboarding",{replace:!0})),window.history.replaceState(null,"",window.location.pathname)}})}else if(w.includes("type=recovery"))o("reset_password");else if(s.get("mode")==="verify_invite"){const p=s.get("token"),l=s.get("email");p&&l&&(n(!0),u.auth.verifyOtp({email:l,token_hash:p,type:"invite"}).then(({error:d})=>{n(!1),d?(a.error("Invalid or expired invite link. "+d.message),o("login")):(a.success("Invite accepted! Please set a password for your account."),o("reset_password"))}))}else s.get("mode")==="reset_password"?o("reset_password"):s.get("mode")==="login"?o("login"):s.get("mode")==="signup"&&o("signup")},[s,x]);const Y=async t=>{var l,d,j,H;t.preventDefault(),n(!0);const w=_.trim(),p=E.trim();try{if(r==="signup"){if(p!==N.trim()){a.error("Passwords do not match"),n(!1);return}const i=le(s),g=ie(s),{data:f,error:h}=await u.auth.signUp({email:w,password:p||"temp-password-placeholder-needs-fixing",options:{emailRedirectTo:window.location.origin,data:{referral_code:I,...M?{customer_referral_code:M}:{},...i?{sls_participant:i}:{},...g?{signup_source:g}:{}}}});if(h)throw h;if(f!=null&&f.user&&(!f.user.identities||f.user.identities.length===0)){a.error("An account with this email address already exists. Please log in."),n(!1);return}a.success("Account created! Please check your email to verify."),C(!0)}else if(r==="login"){b(!0);const{error:i}=await u.auth.signInWithPassword({email:w,password:p});if(i){if(b(!1),(l=i.message)!=null&&l.toLowerCase().includes("email not confirmed")||(d=i.message)!=null&&d.toLowerCase().includes("email address not confirmed")){C(!0),a.error("Please verify your email before logging in. Check your inbox or resend the verification email."),n(!1);return}if((j=i.message)!=null&&j.toLowerCase().includes("invalid login credentials")){a.error("Account does not exist, or invalid login credentials. If you were invited, try resetting your password."),C(!0),n(!1);return}throw i}const{data:g}=await u.auth.mfa.getAuthenticatorAssuranceLevel();if(g&&g.nextLevel==="aal2"&&g.currentLevel!=="aal2"){const{data:h}=await u.auth.mfa.listFactors(),J=(H=h==null?void 0:h.totp)==null?void 0:H.find($=>$.status==="verified");if(J){U(J.id),o("mfa_challenge"),b(!1),n(!1);return}}b(!1);const f=s.get("redirect")||"/app/onboarding";sessionStorage.getItem("forzi_post_login_redirect")||sessionStorage.setItem("forzi_post_login_redirect",f),x("/app",{replace:!0})}else if(r==="mfa_challenge"){if(!F||R.trim().length!==6){a.error("Enter the 6-digit code from your authenticator app."),n(!1);return}const{data:i,error:g}=await u.auth.mfa.challenge({factorId:F});if(g)throw g;const{error:f}=await u.auth.mfa.verify({factorId:F,challengeId:i.id,code:R.trim()});if(f)throw f;const h=s.get("redirect")||"/app/onboarding";sessionStorage.getItem("forzi_post_login_redirect")||sessionStorage.setItem("forzi_post_login_redirect",h),x("/app",{replace:!0})}else if(r==="forgot_password"){const{error:i}=await u.auth.resetPasswordForEmail(w,{redirectTo:window.location.origin+"/auth?type=recovery"});if(i)throw i;a.success("Password reset link sent to your email."),o("login")}else if(r==="reset_password"){if(p!==N.trim()){a.error("Passwords do not match"),n(!1);return}const{data:{session:i}}=await u.auth.getSession();if(!i){a.error("Session could not be established from the link. Please request a new reset email."),n(!1);return}const{error:g}=await u.auth.updateUser({password:p});if(g)throw g;a.success("Password updated successfully.");const f=s.get("redirect")||"/app/onboarding";sessionStorage.getItem("forzi_post_login_redirect")||sessionStorage.setItem("forzi_post_login_redirect",f),x("/app",{replace:!0})}}catch(i){b(!1),a.error(i.message||"Authentication failed")}finally{n(!1)}},Z=async()=>
1{if(!_){a.error("Please enter your email address first");return}n(!0);const{error:t}=await u.auth.resend({type:"signup",email:_,options:{emailRedirectTo:window.location.origin}});n(!1),t?a.error(t.message):(a.success("Verification email sent! Please check your inbox."),C(!1))};return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-background px-6 py-12 font-sans relative overflow-hidden",children:[e.jsx(oe,{title:"Sign In",description:"Sign in to Forzi.",canonical:"/auth",noIndex:!0}),e.jsx("div",{className:"absolute inset-0 bg-[linear-gradient(hsl(var(--border)/0.2)_1px,transparent_1px),linear-gradient(90deg,hsl(var(--border)/0.2)_1px,transparent_1px)] bg-[size:56px_56px] [mask-image:radial-gradient(ellipse_80%_65%_at_50%_40%,black_30%,transparent_100%)] pointer-events-none"}),e.jsx("div",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[800px] h-[600px] rounded-full bg-primary/5 blur-[180px] pointer-events-none"}),e.jsxs("div",{className:"w-full max-w-[440px] relative z-10",children:[e.jsxs(q.div,{initial:{opacity:0,y:-20},animate:{opacity:1,y:0},transition:{duration:.6,ease:"easeOut"},className:"text-center mb-8 flex flex-col items-center",children:[e.jsx(z,{to:"/",className:"inline-block mb-6",children:e.jsx(ne,{className:"h-10 w-auto"})}),e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-foreground mb-2",children:r==="login"?"Log in to Forzi":r==="signup"?"Sign up to Forzi":r==="forgot_password"?"Reset your password":r==="mfa_challenge"?"Two-factor authentication":"Set new password"}),e.jsx("p",{className:"text-[15px] text-muted-foreground",children:r==="login"?"Welcome back to your workspace.":r==="signup"?"Start using Forzi today. Backed by a money-back guarantee.":r==="forgot_password"?"Enter your email to receive a reset link.":r==="mfa_challenge"?"Enter the 6-digit code from your authenticator app.":"Enter your new password below."})]}),e.jsxs(q.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.1,ease:"easeOut"},className:"bg-card/60 backdrop-blur-xl rounded-[32px] p-8 sm:p-10 border border-border shadow-2xl relative",children:[e.jsx("div",{className:"absolute top-0 right-0 w-[200px] h-[200px] bg-primary/5 blur-[80px] pointer-events-none rounded-full"}),e.jsx("div",{className:"relative",children:e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[(r==="login"||r==="signup"||r==="forgot_password")&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground/80",children:"Work email*"}),e.jsx(y,{type:"email",placeholder:"Enter your email",value:_,onChange:t=>G(t.target.value),required:!0,className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px]"})]}),(r==="login"||r==="reset_password")&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground/80",children:r==="reset_password"?"New Password*":"Password*"}),r==="login"&&e.jsx("button",{type:"button",onClick:()=>o("forgot_password"),className:"text-[13px] text-muted-foreground hover:text-primary transition-colors",children:"Forgot password?"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{type:m?"text":"password",placeholder:"Enter your password",value:E,onChange:t=>T(t.target.value),required:!0,minLength:6,className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px] pr-10"}),e.jsx("button",{type:"button",onClick:()=>S(!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:m?e.jsx(P,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})})]})]}),r==="signup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground/80",children:"Password*"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{type:m?"text":"password",placeholder:"Create a password",value:E,onChange:t=>T(t.target.value),required:!0,minLength:6,className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px] pr-10"}),e.jsx("button",{type:"button",onClick:()=>S(!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:m?e.jsx(P,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground
1/80",children:"Confirm Password*"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{type:m?"text":"password",placeholder:"Confirm your password",value:N,onChange:t=>O(t.target.value),required:!0,minLength:6,className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px] pr-10"}),e.jsx("button",{type:"button",onClick:()=>S(!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:m?e.jsx(P,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-border/50",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground/80",children:"Referral Code (Optional)"}),e.jsx(y,{type:"text",placeholder:"Enter partner referral code",value:I,onChange:t=>Q(t.target.value.toUpperCase()),className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px]"}),I&&e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:"A referral code ensures your inviter receives credit."})]})]}),r==="mfa_challenge"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground/80",children:"6-digit code*"}),e.jsx(y,{type:"text",inputMode:"numeric",placeholder:"000000",value:R,onChange:t=>B(t.target.value.replace(/\D/g,"").slice(0,6)),required:!0,maxLength:6,autoFocus:!0,className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px] font-mono tracking-widest text-center"})]}),r==="reset_password"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{className:"text-[13px] font-semibold text-foreground/80",children:"Confirm Password*"}),e.jsxs("div",{className:"relative",children:[e.jsx(y,{type:m?"text":"password",placeholder:"Confirm your password",value:N,onChange:t=>O(t.target.value),required:!0,minLength:6,className:"h-12 rounded-xl bg-background/50 border-border/50 focus-visible:ring-primary/30 text-[15px] pr-10"}),e.jsx("button",{type:"button",onClick:()=>S(!m),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:m?e.jsx(P,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"pt-3",children:e.jsx(A,{type:"submit",variant:"hero",className:"w-full h-12 rounded-full font-semibold text-[15px] shadow-lg shadow-primary/20 hover:shadow-primary/40 transition-all",disabled:k,children:k?"Please wait...":r==="login"?"Log in":r==="signup"?"Create Account":r==="forgot_password"?"Send reset link":r==="mfa_challenge"?"Verify":"Update password"})}),X&&(r==="login"||r==="signup")&&e.jsxs("div",{className:"pt-2 flex flex-col gap-2",children:[e.jsx(A,{type:"button",variant:"outline",className:"w-full h-12 rounded-full font-medium text-[14px] border-primary/20 hover:bg-primary/5 text-primary",onClick:Z,disabled:k,children:"Resend verification email"}),r==="login"&&e.jsx(A,{type:"button",variant:"outline",className:"w-full h-12 rounded-full font-medium text-[14px] border-border hover:bg-muted text-muted-foreground",onClick:()=>o("forgot_password"),disabled:k,children:"Reset password instead"})]})]})})]}),e.jsxs(q.div,{initial:{opacity:0}
1,animate:{opacity:1},transition:{duration:.6,delay:.3},children:[(r==="signup"||r==="login")&&e.jsxs("div",{className:"mt-8 text-center space-y-4",children:[r==="signup"&&e.jsxs("p",{className:"text-[13px] text-muted-foreground/70",children:["By using Forzi you are agreeing to our ",e.jsx(z,{to:"/privacy",className:"text-foreground underline underline-offset-2 hover:text-primary transition-colors",children:"privacy policy"})," and ",e.jsx(z,{to:"/terms",className:"text-foreground underline underline-offset-2 hover:text-primary transition-colors",children:"terms"}),"."]}),e.jsx("p",{className:"text-[14px] text-muted-foreground",children:r==="signup"?e.jsxs(e.Fragment,{children:["Already have an account? ",e.jsx("button",{onClick:()=>o("login"),className:"text-primary font-medium hover:underline",children:"Login"})]}):e.jsxs(e.Fragment,{children:["Don't have an account? ",e.jsx("button",{onClick:()=>o("signup"),className:"text-primary font-medium hover:underline",children:"Sign up"})]})})]}),(r==="forgot_password"||r==="reset_password")&&e.jsx("div",{className:"mt-8 text-center",children:e.jsxs("p",{className:"text-[14px] text-muted-foreground",children:["Remembered your password?"," ",e.jsx("button",{onClick:()=>o("login"),className:"text-primary font-medium hover:underline",children:"Log in"})]})}),r==="mfa_challenge"&&e.jsx("div",{className:"mt-8 text-center",children:e.jsx("p",{className:"text-[14px] text-muted-foreground",children:e.jsx("button",{onClick:async()=>{await u.auth.signOut(),o("login"),U(null),B("")},className:"text-primary font-medium hover:underline",children:"Use a different account"})})})]})]})]})};export{we 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.