All blocks
Login SSO
Enterprise single sign-on flow with work-email domain lookup, SAML 2.0 and OIDC identity provider confirmation (Okta, Microsoft Entra ID, Google Workspace), password fallback with inline validation, and toast feedback.
Built withAlertAvatarBadgeButtonCardCenterFieldHeadingIconInputLinkPassword InputSeparatorSpinnerStackTextToast
Sign in to Helios
Enter your work email to connect with your organization's identity provider.
Don't have a workspace seat? Request access
Install
1npx stylexblocks add login-ssoSource
components/blocks/ui-sdk/login-sso.tsx
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152import * as stylex from "@stylexjs/stylex";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { Alert } from "#components/ui/ui-sdk/alert.tsx";import { Avatar } from "#components/ui/ui-sdk/avatar.tsx";import { Badge } from "#components/ui/ui-sdk/badge.tsx";import { Button } from "#components/ui/ui-sdk/button.tsx";import { Card } from "#components/ui/ui-sdk/card.tsx";import { Center, Circle, Square } from "#components/ui/ui-sdk/center.tsx";import { Field } from "#components/ui/ui-sdk/field.tsx";import { Heading } from "#components/ui/ui-sdk/heading.tsx";import { Icon } from "#components/ui/ui-sdk/icon.tsx";import { Input } from "#components/ui/ui-sdk/input.tsx";import { Link } from "#components/ui/ui-sdk/link.tsx";import { PasswordInput } from "#components/ui/ui-sdk/password-input.tsx";import { Separator } from "#components/ui/ui-sdk/separator.tsx";import { Spinner } from "#components/ui/ui-sdk/spinner.tsx";import { HStack, VStack } from "#components/ui/ui-sdk/stack.tsx";import { Text } from "#components/ui/ui-sdk/text.tsx";import { Toast, Toaster } from "#components/ui/ui-sdk/toast.tsx";import { semanticColors } from "@stylexblocks/ui/semantic-tokens/colors.stylex.ts";import { semanticRadii } from "@stylexblocks/ui/semantic-tokens/radii.stylex.ts";import { semanticShadows } from "@stylexblocks/ui/semantic-tokens/shadows.stylex.ts";import { accentPalette, bluePalette, emeraldPalette, indigoPalette,} from "@stylexblocks/ui/themes/palettes.ts";import { fontSizes } from "@stylexblocks/ui/tokens/font-sizes.stylex.ts";import { fonts } from "@stylexblocks/ui/tokens/fonts.stylex.ts";import { lineHeights } from "@stylexblocks/ui/tokens/line-heights.stylex.ts";import { radii } from "@stylexblocks/ui/tokens/radii.stylex.ts";import { spacing } from "@stylexblocks/ui/tokens/spacing.stylex.ts";import type { StyleOverrideProps } from "#lib/recipe-props.ts";
// ── Types & Demo Data ─────────────────────────────────────────────────────────
export type SsoProviderPalette = "indigo" | "blue" | "emerald";
export interface SsoProviderConfig { id: string; name: string; abbr: string; protocol: "SAML 2.0" | "OIDC"; tenantHost: string; palette: SsoProviderPalette;}
export interface LoginSsoProps extends StyleOverrideProps { /** Workspace name shown across the authentication flow. */ workspaceName?: string; /** Primary heading on the initial sign-in step. */ title?: string; /** Supporting subtitle beneath the initial heading. */ description?: string; /** Domain-to-identity-provider lookup map keyed by lowercase email domain. */ providers?: Record<string, SsoProviderConfig>; /** Initial email address pre-filled in the work email input. */ defaultEmail?: string; /** Optional backdrop artwork URL or data URI rendered behind the card. */ backdropSrc?: string; /** Called when an enterprise SSO redirect is confirmed. */ onSsoRedirect?: (payload: { email: string; provider: SsoProviderConfig }) => void; /** Called when password sign-in succeeds. */ onPasswordSignIn?: (payload: { email: string }) => void;}
const DEFAULT_SSO_PROVIDERS: Record<string, SsoProviderConfig> = { "helioslabs.io": { id: "okta", name: "Okta", abbr: "OK", protocol: "SAML 2.0", tenantHost: "helios.okta.com", palette: "indigo", }, "okta.com": { id: "okta", name: "Okta", abbr: "OK", protocol: "SAML 2.0", tenantHost: "id.okta.com", palette: "indigo", }, "northstar.co": { id: "entra", name: "Microsoft Entra ID", abbr: "ME", protocol: "OIDC", tenantHost: "login.microsoftonline.com/northstar", palette: "blue", }, "microsoft.com": { id: "entra", name: "Microsoft Entra ID", abbr: "ME", protocol: "OIDC", tenantHost: "login.microsoftonline.com", palette: "blue", }, "veridian.design": { id: "google", name: "Google Workspace", abbr: "GW", protocol: "SAML 2.0", tenantHost: "accounts.google.com/o/saml2", palette: "emerald", }, "google.com": { id: "google", name: "Google Workspace", abbr: "GW", protocol: "SAML 2.0", tenantHost: "accounts.google.com/o/saml2", palette: "emerald", },};
const SAMPLE_ACCOUNTS: Array<{ email: string; label: string }> = [ { email: "maya@helioslabs.io", label: "Okta" }, { email: "devon@northstar.co", label: "Entra ID" }, { email: "claire@veridian.design", label: "Google" }, { email: "alex@studio.org", label: "Password" },];
type AuthStep = "email" | "sso-confirm" | "password-fallback" | "signed-in";type FallbackReason = "no-sso" | "manual";
function extractDomain(email: string): string | null { const parts = email.trim().toLowerCase().split("@"); if (parts.length !== 2 || !parts[1]) return null; return parts[1];}
function isValidEmail(email: string): boolean { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());}
function resolvePalette(key: SsoProviderPalette) { if (key === "blue") return bluePalette; if (key === "emerald") return emeraldPalette; return indigoPalette;}
// ── Inline SVG Icons ──────────────────────────────────────────────────────────
function HeliosMark() { return ( <Square render={<span />} size="md" style={styles.brandMark} aria-hidden="true"> <Icon size="md" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" > <circle cx="12" cy="12" r="4" /> <path d="M12 3v2.5" /> <path d="M12 18.5V21" /> <path d="M3 12h2.5" /> <path d="M18.5 12H21" /> <path d="m5.64 5.64 1.77 1.77" /> <path d="m16.59 16.59 1.77 1.77" /> <path d="m18.36 5.64-1.77 1.77" /> <path d="m7.41 16.59-1.77 1.77" /> </Icon> </Square> );}
function ShieldCheckIcon() { return ( <Icon size="md" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M10 2.5 16 5v4.5c0 3.7-2.55 6.85-6 8-3.45-1.15-6-4.3-6-8V5l6-2.5Z" /> <path d="m7.5 10.2 1.7 1.7 3.5-3.7" /> </Icon> );}
function KeyIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="7.5" cy="10" r="3.5" /> <path d="M11 10h6.5" /> <path d="M15 10v2.5" /> <path d="M17.5 10v2" /> </Icon> );}
function ArrowRightIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <path d="M4.5 10h11" /> <path d="M11 5.5 15.5 10 11 14.5" /> </Icon> );}
function CheckCircleIcon() { return ( <Icon size="md" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="10" cy="10" r="7.5" /> <path d="m7 10.3 2 2 4-4.5" /> </Icon> );}
function InfoCircleIcon() { return ( <Icon size="sm" viewBox="0 0 20 20" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true" > <circle cx="10" cy="10" r="7.5" /> <path d="M10 9.2v4.2" /> <path d="M10 6.5h.01" /> </Icon> );}
// ── Styles ────────────────────────────────────────────────────────────────────
const styles = stylex.create({ root: { backgroundColor: semanticColors.bg, color: semanticColors.fg, fontFamily: fonts.body, minHeight: "100%", overflowX: "hidden", overflowY: "auto", paddingBlock: spacing._8, paddingInline: spacing._4, position: "relative", width: "100%", }, backdropImage: { height: "100%", left: 0, objectFit: "cover", pointerEvents: "none", position: "absolute", top: 0, userSelect: "none", width: "100%", zIndex: 0, }, backdropScrim: { backgroundColor: semanticColors.bg, height: "100%", left: 0, opacity: 0.36, pointerEvents: "none", position: "absolute", top: 0, width: "100%", zIndex: 1, }, stage: { maxWidth: "26.5rem", position: "relative", width: "100%", zIndex: 2, }, card: { boxShadow: semanticShadows.xl, width: "100%", }, cardBody: { gap: spacing._5, paddingBlock: { default: spacing._8, "@media (max-width: 480px)": spacing._6, }, paddingInline: { default: spacing._8, "@media (max-width: 480px)": spacing._5, }, }, header: { textAlign: "center", }, brandMark: { backgroundColor: semanticColors.accentSubtle, borderColor: semanticColors.accentBorder, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", color: semanticColors.accentFg, marginBottom: spacing._1, }, heading: { marginBlock: 0, textAlign: "center", textWrap: "balance", }, subtitle: { maxWidth: "34ch", }, fieldsStack: { gap: spacing._3_5, width: "100%", }, helperLink: { fontSize: fontSizes.xs, lineHeight: lineHeights.xs, }, dividerLine: { flexBasis: 0, flexGrow: 1, flexShrink: 1, minWidth: 0, width: "auto", }, dividerLabel: { flexShrink: 0, whiteSpace: "nowrap", }, fullWidth: { width: "100%", }, providerCard: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.border, borderStyle: "solid", borderWidth: "1px", width: "100%", }, providerCardBody: { alignItems: "center", flexDirection: "row", gap: spacing._3, paddingBlock: spacing._3_5, paddingInline: spacing._4, }, providerIconWrap: { color: semanticColors.fgMuted, flexShrink: 0, }, providerMeta: { flexBasis: 0, flexGrow: 1, flexShrink: 1, }, accountPill: { backgroundColor: semanticColors.bgMuted, borderColor: semanticColors.border, borderRadius: radii.full, borderStyle: "solid", borderWidth: "1px", display: "inline-flex", maxWidth: "100%", paddingBlock: spacing._1, paddingInlineEnd: spacing._2, paddingInlineStart: spacing._3, }, successBadgeWrap: { backgroundColor: semanticColors.bgSuccess, borderColor: semanticColors.borderSuccess, borderStyle: "solid", borderWidth: "1px", color: semanticColors.fgSuccess, marginBottom: spacing._1, }, sessionSummaryBody: { gap: spacing._2_5, paddingBlock: spacing._3_5, paddingInline: spacing._4, }, demoStrip: { backgroundColor: semanticColors.bgOverlay, borderColor: semanticColors.border, borderRadius: semanticRadii.panel, borderStyle: "solid", borderWidth: "1px", boxShadow: semanticShadows.md, paddingBlock: spacing._3, paddingInline: spacing._4, width: "100%", },});
// ── Component ─────────────────────────────────────────────────────────────────
/** * LoginSso — enterprise SSO sign-in block with work-email domain lookup, * SAML 2.0 / OIDC identity provider confirmation (Okta, Microsoft Entra ID, * Google Workspace), password fallback with inline validation, and toast * feedback over an atmospheric architectural backdrop. */export function LoginSso({ workspaceName = "Helios Workspace", title = "Sign in to Helios", description = "Enter your work email to connect with your organization's identity provider.", providers = DEFAULT_SSO_PROVIDERS, defaultEmail = "", backdropSrc = "/images/blocks/login-sso/dusk-towers.webp", onSsoRedirect, onPasswordSignIn, palette, style,}: LoginSsoProps) { const queue = useMemo(() => Toast.createToaster(), []); const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const [step, setStep] = useState<AuthStep>("email"); const [fallbackReason, setFallbackReason] = useState<FallbackReason>("no-sso"); const [email, setEmail] = useState(defaultEmail); const [password, setPassword] = useState(""); const [emailError, setEmailError] = useState<string | null>(null); const [passwordError, setPasswordError] = useState<string | null>(null); const [isLoading, setIsLoading] = useState(false); const [authMethodLabel, setAuthMethodLabel] = useState("");
const clearPendingTimer = useCallback(() => { if (timerRef.current !== null) { clearTimeout(timerRef.current); timerRef.current = null; } }, []);
useEffect(() => clearPendingTimer, [clearPendingTimer]);
const normalizedEmail = email.trim(); const domain = extractDomain(normalizedEmail); const detectedProvider = domain ? (providers[domain] ?? null) : null; const emailValid = isValidEmail(normalizedEmail);
const handleEmailChange = useCallback((next: string) => { setEmail(next); setEmailError(null); }, []);
const handlePasswordChange = useCallback((next: string) => { setPassword(next); setPasswordError(null); }, []);
const verifyPasswordSignIn = useCallback( (targetEmail: string, candidatePassword: string) => { if (!candidatePassword.trim()) { setPasswordError("Enter your password to continue."); return; } if (candidatePassword.length < 6) { setPasswordError("Password must be at least 6 characters."); return; } if (candidatePassword.trim().toLowerCase() === "wrong") { setPasswordError("Incorrect password. Check your credentials and try again."); return; }
clearPendingTimer(); setIsLoading(true); setPasswordError(null);
timerRef.current = setTimeout(() => { timerRef.current = null; setIsLoading(false); setAuthMethodLabel("Workspace password"); setStep("signed-in"); onPasswordSignIn?.({ email: targetEmail }); queue.success(`Signed in to ${workspaceName}`, { description: `Authenticated as ${targetEmail}.`, }); }, 900); }, [clearPendingTimer, onPasswordSignIn, queue, workspaceName], );
const handleEmailStepSubmit = useCallback( (event: React.FormEvent<HTMLFormElement>) => { event.preventDefault(); if (!emailValid) { setEmailError("Enter a valid work email address (for example, maya@helioslabs.io)."); return; }
setEmailError(null);
if (detectedProvider) { setStep("sso-confirm"); return; }
if (password.trim().length > 0) { verifyPasswordSignIn(normalizedEmail, password); return; }
setFallbackReason("no-sso"); setPasswordError(null); setStep("password-fallback"); }, [detectedProvider, emailValid, normalizedEmail, password, verifyPasswordSignIn], );
const handleSsoLookup = useCallback(() => { if (!emailValid) { setEmailError("Enter your work email first so we can look up your SSO provider."); queue.info("Work email required for SSO", { description: "Try a managed domain like maya@helioslabs.io or devon@northstar.co.", }); return; }
setEmailError(null);
if (detectedProvider) { setStep("sso-confirm"); return; }
setFallbackReason("no-sso"); setPasswordError(null); setStep("password-fallback"); queue.info(`No SSO provider found for ${domain ?? "this domain"}`, { description: "Continue with your workspace password instead.", }); }, [detectedProvider, domain, emailValid, queue]);
const handleSsoConfirm = useCallback(() => { if (!detectedProvider || isLoading) return;
clearPendingTimer(); setIsLoading(true); onSsoRedirect?.({ email: normalizedEmail, provider: detectedProvider }); queue.info(`Redirecting to ${detectedProvider.name}…`, { description: `Validating ${detectedProvider.protocol} assertion for ${normalizedEmail}.`, });
timerRef.current = setTimeout(() => { timerRef.current = null; setIsLoading(false); setAuthMethodLabel(`${detectedProvider.name} · ${detectedProvider.protocol}`); setStep("signed-in"); queue.success(`Authenticated via ${detectedProvider.name}`, { description: `Welcome back to ${workspaceName}, ${normalizedEmail}.`, }); }, 1100); }, [ clearPendingTimer, detectedProvider, isLoading, normalizedEmail, onSsoRedirect, queue, workspaceName, ]);
const handlePasswordFallbackSubmit = useCallback( (event: React.FormEvent<HTMLFormElement>) => { event.preventDefault(); verifyPasswordSignIn(normalizedEmail, password); }, [normalizedEmail, password, verifyPasswordSignIn], );
const handleBackToEmail = useCallback(() => { clearPendingTimer(); setIsLoading(false); setPasswordError(null); setStep("email"); }, [clearPendingTimer]);
const handleResetFlow = useCallback(() => { clearPendingTimer(); setIsLoading(false); setPassword(""); setEmailError(null); setPasswordError(null); setStep("email"); }, [clearPendingTimer]);
const handleSelectSample = useCallback( (sampleEmail: string) => { clearPendingTimer(); setIsLoading(false); setEmail(sampleEmail); setPassword(""); setEmailError(null); setPasswordError(null); setStep("email"); }, [clearPendingTimer], );
const handleSupportClick = useCallback( (event: React.MouseEvent<HTMLAnchorElement>) => { event.preventDefault(); queue.info("IT helpdesk notified", { description: "Check your organization's identity portal or contact security@helioslabs.io.", }); }, [queue], );
const handleForgotPasswordClick = useCallback( (event: React.MouseEvent<HTMLAnchorElement>) => { event.preventDefault(); queue.success("Password reset email sent", { description: `If ${normalizedEmail || "that address"} has a local password, reset instructions are on the way.`, }); }, [normalizedEmail, queue], );
const handleRequestAccessClick = useCallback( (event: React.MouseEvent<HTMLAnchorElement>) => { event.preventDefault(); queue.info("Workspace access request", { description: `Ask your ${workspaceName} administrator to provision your seat via SCIM or invite.`, }); }, [queue, workspaceName], );
const handleSwitchToPasswordFallback = useCallback( (event: React.MouseEvent<HTMLAnchorElement>) => { event.preventDefault(); clearPendingTimer(); setIsLoading(false); setFallbackReason("manual"); setPasswordError(null); setStep("password-fallback"); }, [clearPendingTimer], );
return ( <VStack align="center" justify="center" gap="0" palette={palette} style={[styles.root, style]} > <img src={backdropSrc} alt="" aria-hidden="true" {...stylex.props(styles.backdropImage)} /> <div aria-hidden="true" {...stylex.props(styles.backdropScrim)} />
<VStack render={<main />} align="center" gap="4" style={styles.stage}> <Card.Root variant="elevated" size="lg" style={styles.card}> <Card.Body style={styles.cardBody}> {/* ── Step 1: Work email & SSO lookup ── */} {step === "email" ? ( <> <VStack render={<header />} align="center" gap="2" style={styles.header}> <HeliosMark /> <Heading render={<h1 />} size="2xl" style={styles.heading}> {title} </Heading> <Text variant="muted" size="sm" align="center" style={styles.subtitle}> {description} </Text> </VStack>
<VStack render={<form noValidate onSubmit={handleEmailStepSubmit} />} gap="4" style={styles.fullWidth} > <VStack style={styles.fieldsStack}> <Field.Root invalid={Boolean(emailError)}> <HStack gap="2" justify="between" style={styles.fullWidth}> <Field.Label>Work email</Field.Label> {detectedProvider ? ( <Badge variant="subtle" size="xs" palette={resolvePalette(detectedProvider.palette)} > {detectedProvider.name} · {detectedProvider.protocol} </Badge> ) : null} </HStack> <Input type="email" size="lg" autoComplete="email" placeholder="maya@helioslabs.io" value={email} onValueChange={handleEmailChange} /> {emailError ? <Field.Error match>{emailError}</Field.Error> : null} </Field.Root>
<PasswordInput.Root size="lg" autoComplete="current-password" value={password} onValueChange={handlePasswordChange} invalid={Boolean(passwordError)} > <HStack gap="2" justify="between" style={styles.fullWidth}> <PasswordInput.Label>Password</PasswordInput.Label> <Link href="#help" variant="plain" style={styles.helperLink} onClick={handleSupportClick} > Trouble signing in? </Link> </HStack> <PasswordInput.Control> <PasswordInput.Input placeholder={ detectedProvider ? "Not required for SSO domains" : "Enter password" } /> <PasswordInput.VisibilityTrigger /> </PasswordInput.Control> {passwordError ? ( <Field.Error match>{passwordError}</Field.Error> ) : null} </PasswordInput.Root> </VStack>
<VStack gap="2.5" style={styles.fullWidth}> <Button type="submit" variant="solid" size="lg" palette={accentPalette} disabled={isLoading} style={styles.fullWidth} > {isLoading ? ( <> <Spinner size="sm" /> Signing in… </> ) : detectedProvider ? ( <> Continue with {detectedProvider.name} <ArrowRightIcon /> </> ) : ( "Sign in" )} </Button>
<HStack gap="3" style={styles.fullWidth}> <Separator decorative style={styles.dividerLine} /> <Text render={<span />} variant="caption" style={styles.dividerLabel}> Or sign in with </Text> <Separator decorative style={styles.dividerLine} /> </HStack>
<Button type="button" variant="surface" size="lg" disabled={isLoading} onClick={handleSsoLookup} style={styles.fullWidth} > <KeyIcon /> Continue with SSO </Button> </VStack> </VStack>
<Text variant="caption" align="center"> Don't have a workspace seat?{" "} <Link href="#request-access" variant="underline" palette={accentPalette} onClick={handleRequestAccessClick} > Request access </Link> </Text> </> ) : null}
{/* ── Step 2a: SSO provider detected ── */} {step === "sso-confirm" && detectedProvider ? ( <> <VStack render={<header />} align="center" gap="2" style={styles.header}> <Avatar.Root variant="subtle" size="lg" shape="rounded" palette={resolvePalette(detectedProvider.palette)} > <Avatar.Fallback>{detectedProvider.abbr}</Avatar.Fallback> </Avatar.Root> <Heading render={<h1 />} size="2xl" style={styles.heading}> Sign in with {detectedProvider.name} </Heading> <Text variant="muted" size="sm" align="center" style={styles.subtitle}> Your organization uses enterprise single sign-on. You'll return to{" "} {workspaceName} right after authenticating. </Text> </VStack>
<Card.Root variant="subtle" size="md" style={styles.providerCard}> <Card.Body style={styles.providerCardBody}> <Center render={<span />} display="inline" style={styles.providerIconWrap}> <ShieldCheckIcon /> </Center> <VStack gap="0.5" style={styles.providerMeta}> <HStack gap="2" wrap="wrap"> <Text render={<span />} variant="label" size="sm"> {detectedProvider.name} </Text> <Badge variant="subtle" size="xs" palette={resolvePalette(detectedProvider.palette)} > {detectedProvider.protocol} </Badge> </HStack> <Text render={<span />} variant="caption" truncate="true"> {normalizedEmail} </Text> <Text render={<span />} variant="mono" size="xs" tone="subtle" truncate="true" > {detectedProvider.tenantHost} </Text> </VStack> </Card.Body> </Card.Root>
<VStack gap="2.5" style={styles.fullWidth}> <Button type="button" variant="solid" size="lg" palette={accentPalette} disabled={isLoading} onClick={handleSsoConfirm} style={styles.fullWidth} > {isLoading ? ( <> <Spinner size="sm" /> Redirecting to {detectedProvider.name}… </> ) : ( <> Continue to {detectedProvider.name} <ArrowRightIcon /> </> )} </Button> <Button type="button" variant="ghost" size="lg" onClick={handleBackToEmail} style={styles.fullWidth} > Use a different email </Button> </VStack>
<Text variant="caption" align="center"> Local workspace administrator?{" "} <Link href="#password-fallback" variant="underline" palette={accentPalette} onClick={handleSwitchToPasswordFallback} > Use password instead </Link> </Text> </> ) : null}
{/* ── Step 2b: Password fallback ── */} {step === "password-fallback" ? ( <> <VStack render={<header />} align="center" gap="2" style={styles.header}> <HeliosMark /> <Heading render={<h1 />} size="2xl" style={styles.heading}> Enter your password </Heading> <HStack gap="2" style={styles.accountPill}> <Text render={<span />} size="xs" weight="medium" truncate="true"> {normalizedEmail} </Text> <Button type="button" variant="plain" size="2xs" palette={accentPalette} onClick={handleBackToEmail} > Change </Button> </HStack> </VStack>
{fallbackReason === "no-sso" ? ( <Alert.Root status="info" variant="subtle" size="sm" palette={bluePalette} > <Alert.Indicator> <InfoCircleIcon /> </Alert.Indicator> <Alert.Content> <Alert.Description> No SSO provider is linked to <strong>{domain}</strong>. Sign in with your {workspaceName} password. </Alert.Description> </Alert.Content> </Alert.Root> ) : null}
<VStack render={<form noValidate onSubmit={handlePasswordFallbackSubmit} />} gap="4" style={styles.fullWidth} > <PasswordInput.Root size="lg" required autoComplete="current-password" value={password} onValueChange={handlePasswordChange} invalid={Boolean(passwordError)} > <HStack gap="2" justify="between" style={styles.fullWidth}> <PasswordInput.Label>Password</PasswordInput.Label> <Link href="#forgot-password" variant="plain" style={styles.helperLink} onClick={handleForgotPasswordClick} > Forgot password? </Link> </HStack> <PasswordInput.Control> <PasswordInput.Input placeholder="Enter your workspace password" autoFocus /> <PasswordInput.VisibilityTrigger /> </PasswordInput.Control> {passwordError ? ( <Field.Error match>{passwordError}</Field.Error> ) : null} </PasswordInput.Root>
<VStack gap="2.5" style={styles.fullWidth}> <Button type="submit" variant="solid" size="lg" palette={accentPalette} disabled={isLoading} style={styles.fullWidth} > {isLoading ? ( <> <Spinner size="sm" /> Verifying credentials… </> ) : ( "Sign in" )} </Button> <Button type="button" variant="ghost" size="lg" onClick={handleBackToEmail} style={styles.fullWidth} > Use a different email </Button> </VStack> </VStack> </> ) : null}
{/* ── Step 3: Authenticated confirmation ── */} {step === "signed-in" ? ( <> <VStack render={<header />} align="center" gap="2" style={styles.header}> <Circle render={<span />} size="lg" style={styles.successBadgeWrap} aria-hidden="true" > <CheckCircleIcon /> </Circle> <Heading render={<h1 />} size="2xl" style={styles.heading}> You're signed in </Heading> <Text variant="muted" size="sm" align="center" style={styles.subtitle}> Your session for {workspaceName} is verified and ready. </Text> </VStack>
<Card.Root variant="subtle" size="md" style={styles.providerCard}> <Card.Body style={styles.sessionSummaryBody}> <HStack gap="2" justify="between" style={styles.fullWidth}> <Text render={<span />} variant="caption"> Account </Text> <Text render={<span />} size="xs" weight="medium"> {normalizedEmail} </Text> </HStack> <HStack gap="2" justify="between" style={styles.fullWidth}> <Text render={<span />} variant="caption"> Method </Text> <Text render={<span />} size="xs" weight="medium"> {authMethodLabel} </Text> </HStack> <HStack gap="2" justify="between" style={styles.fullWidth}> <Text render={<span />} variant="caption"> Status </Text> <Badge variant="subtle" size="xs" palette={emeraldPalette}> Verified session </Badge> </HStack> </Card.Body> </Card.Root>
<VStack gap="2.5" style={styles.fullWidth}> <Button type="button" variant="solid" size="lg" palette={accentPalette} style={styles.fullWidth} onClick={() => queue.info(`Opening ${workspaceName}…`, { description: `Loading projects for ${normalizedEmail}.`, }) } > Open {workspaceName} <ArrowRightIcon /> </Button> <Button type="button" variant="ghost" size="lg" onClick={handleResetFlow} style={styles.fullWidth} > Sign in with another account </Button> </VStack> </> ) : null} </Card.Body> </Card.Root>
{/* Quick-fill demo strip so reviewers can exercise each IdP + fallback */} <VStack render={<aside aria-label="Sample enterprise domains" />} align="center" gap="2" style={styles.demoStrip} > <Text variant="caption">Try a sample work email:</Text> <HStack gap="1.5" justify="center" wrap="wrap"> {SAMPLE_ACCOUNTS.map((sample) => ( <Button key={sample.email} type="button" variant="subtle" size="2xs" onClick={() => handleSelectSample(sample.email)} > {sample.label} </Button> ))} </HStack> </VStack> </VStack>
<Toaster toaster={queue} /> </VStack> );}
Inspired by the Login SSO template from Astryx (MIT License · Copyright (c) 2026 Meta Platforms, Inc.).
