PageSourceSearch

https://zaher.ai/assets/OAuthMicrosoftCallback-DxFtUw2R.js

js zaher.ai collected 2026-10-05 13:21:53 UTC 3,469 bytes, 1 lines download raw bytes

1import{m as y,f as v,b,g as k,bb as A,q as w,r as x,j as o}from"./index-BgyAUjrd.js";import{r as c}from"./react-vendor-DMqmElJU.js";import{A as P}from"./AuthLayout-BXrTJeen.js";import{c as N}from"./anonymousAuditSessionApi-B3lFRvdm.js";const j={missing_state:"Sign-in session was lost. Please try again.",expired_state:"Your sign-in attempt expired. Please try again.",invalid_state:"Sign-in session was invalid. Please try again.",token_exchange_failed:"Could not verify your Microsoft sign-in. Please try again.",email_not_verified:"Your Microsoft email is not verified.",account_inactive:"Your account is disabled. Contact support.",service_unavailable:"Sign-in service is temporarily unavailable. Please try again.",access_denied:"Sign-in was cancelled."};function T(){const[n]=y(),t=v(),{toast:i}=b(),{setToken:m}=k(),[g,l]=c.useState("working"),[h,u]=c.useState(""),d=c.useRef(!1);return c.useEffect(()=>{if(d.current)return;d.current=!0;const f=n.get("error"),p=n.get("code");if(f){const s=n.get("message")||j[f]||"Microsoft sign-in failed. Please try again.";u(s),l("error"),i({title:"Microsoft sign-in failed",description:s,variant:"destructive"});return}if(!p){u("Missing sign-in code."),l("error");return}(async()=>{try{const s=await fetch("/api/auth/microsoft/finish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:p})});if(!s.ok){const a=await s.json().catch(()=>({}));throw new Error(a.message||"Could not complete sign-in")}const e=await s.json();if(m(e.token,{id:e.user.id,fullName:e.user.fullName,username:e.user.username,email:e.user.email,role:e.user.role,plan:e.user.plan??void 0}),localStorage.removeItem("anonymousAuditToken"),localStorage.removeItem("anonymousAuditDomain"),localStorage.removeItem("anonymousBusinessProfile"),localStorage.removeItem("signupDraft"),localStorage.removeItem("businessProfileCache"),localStorage.removeItem("onboardingDraft"),typeof sessionStorage<"u"&&sessionStorage.removeItem("zaher-domain"),e.isNewUser&&A("microsoft"),e.pendingGateCommit&&e.gateAccessToken){try{const a=await N(e.gateAccessToken);t(a.redirectTo||"/app",{replace:!0})}catch{t("/app",{replace:!0})}i({title:"Account created",description:"Welcome to Zaher.AI!"});return}const S=w(e.user),r=e.signupDomain??null;if(S)t(x(e.user),{replace:!0});else if(e.onboardingToken){const a=new URLSearchParams({token:e.onboardingToken});r&&a.set("domain",r),t(`/onboarding?${a.toString()}`,{replace:!0})}else if(e.isNewUser&&!e.linkedFromAnonymous){const a=r?`?domain=${encodeURIComponent(r)}`:"";t(`/onboarding${a}`,{replace:!0})}else t("/app",{replace:!0});i({title:e.isNewUser?"Account created":"Signed in",description:e.isNewUser?"Welcome to Zaher.AI!":"Welcome back to Zaher.AI."})}catch(s){const e=s instanceof Error?s.message:"Sign-in failed";u(e),l("error"),i({title:"Microsoft sign-in failed",description:e,variant:"destructive"})}})()},[n,t,m,i]),o.jsxs(P,{children:[o.jsx("h1",{className:"auth-card-title",children:g==="working"?"Signing you in…":"Sign-in failed"}),g==="working"?o.jsxs("p",{className:"auth-card-sub",style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("span",{className:"auth-spinner"})," Completing your Microsoft sign-in."]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"auth-card-sub",style:{marginBottom:24},children:h}),o.jsx("button",{type:"button",className:"btn-primary",onClick:()=>t("/login",{replace:!0}),children:"Back to login"})]})]})}export{T 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.