Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(auth): add auth flow variant system (#61280)

Fernando Gomes9ed0863de94c
diff --git a/frontend/jest.config.ts b/frontend/jest.config.ts
index 226a59bf10be..353399d76206 100644
--- a/frontend/jest.config.ts
+++ b/frontend/jest.config.ts
@@ -13,6 +13,9 @@ const esmModules = [
'@medv',
'monaco-editor',
'@posthog/hedgehog-mode',
+ // @marsidev/react-turnstile ships ESM-only; the auth flow variant registry pulls it
+ // into test module graphs (including Exporter via the shared login ERROR_MESSAGES export).
+ '@marsidev/react-turnstile',
'escape-string-regexp',
'@tiptap',
'@mathjax',
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 4275ada007e8..8fa39f7dd044 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -172,6 +172,7 @@ export const FEATURE_FLAGS = {
// Feature flags used to control opt-in for different behaviors, should not be removed
AI_TRAINING: 'ai-training', // owner: @nicowaltz #team-replay #ai-research, gates the AI training opt-out UI and API enforcement
AUDIT_LOGS_ACCESS: 'audit-logs-access', // owner: #team-platform-features, used to control access to audit logs
+ AUTH_FLOW_VARIANT: 'auth-flow-variant', // owner: @fercgomes #team-growth multivariate=legacy,redesign-2026-06-02 — selects the signin/signup experience (login, signup, invited signup); legacy is the existing design
BATCH_EXPORT_EARLIEST_BACKFILL: 'batch-export-earliest-backfill', // owner: #team-batch-exports, allow backfilling from beginning of time
CONTROL_SUPPORT_LOGIN: 'control_support_login', // owner: #team-security, used to control whether users can opt out of support impersonation
CUSTOM_CSS_THEMES: 'custom-css-themes', // owner: #team-growth, used to enable custom CSS for teams who want to have fun
diff --git a/frontend/src/scenes/authentication/authFlowVariantRegistry.tsx b/frontend/src/scenes/authentication/authFlowVariantRegistry.tsx
new file mode 100644
index 000000000000..269f67554061
--- /dev/null
+++ b/frontend/src/scenes/authentication/authFlowVariantRegistry.tsx
@@ -0,0 +1,19 @@
+import type { AuthFlowVariant } from './authFlowVariants'
+import { LegacyInviteSignup } from './invite-signup/variants/legacy/LegacyInviteSignup'
+import { InviteSignupV2 } from './invite-signup/variants/redesign-2026-06-02/InviteSignupV2'
+import { LegacyLogin } from './login/variants/legacy/LegacyLogin'
+import { LoginV2 } from './login/variants/redesign-2026-06-02/LoginV2'
+import { LegacySignup } from './signup/variants/legacy/LegacySignup'
+import { SignupV2 } from './signup/variants/redesign-2026-06-02/SignupV2'
+
+interface AuthFlowVariantComponents {
+ Login: () => JSX.Element | null
+ Signup: () => JSX.Element | null
+ InviteSignup: () => JSX.Element | null
+}
+
+// One variant value selects login, signup and invited signup together.
+export const authFlowVariantRegistry: Record<AuthFlowVariant, AuthFlowVariantComponents> = {
+ legacy: { Login: LegacyLogin, Signup: LegacySignup, InviteSignup: LegacyInviteSignup },
+ 'redesign-2026-06-02': { Login: LoginV2, Signup: SignupV2, InviteSignup: InviteSignupV2 },
+}
diff --git a/frontend/src/scenes/authentication/authFlowVariants.ts b/frontend/src/scenes/authentication/authFlowVariants.ts
new file mode 100644
index 000000000000..7f6a66aad1ee
--- /dev/null
+++ b/frontend/src/scenes/authentication/authFlowVariants.ts
@@ -0,0 +1,15 @@
+import { FEATURE_FLAGS } from 'lib/constants'
+import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'
+
+export type AuthFlowVariant = 'legacy' | 'redesign-2026-06-02'
+
+const DEFAULT_VARIANT: AuthFlowVariant = 'legacy'
+
+export const AUTH_FLOW_VARIANTS: AuthFlowVariant[] = ['legacy', 'redesign-2026-06-02']
+
+export function resolveAuthFlowVariant(featureFlags: FeatureFlagsSet): AuthFlowVariant {
+ const variant = featureFlags[FEATURE_FLAGS.AUTH_FLOW_VARIANT]
+ return typeof variant === 'string' && (AUTH_FLOW_VARIANTS as string[]).includes(variant)
+ ? (variant as AuthFlowVariant)
+ : DEFAULT_VARIANT
+}
diff --git a/frontend/src/scenes/authentication/invite-signup/InviteSignup.tsx b/frontend/src/scenes/authentication/invite-signup/InviteSignup.tsx
index 57224e2ef1de..41a9a6e76fec 100644
--- a/frontend/src/scenes/authentication/invite-signup/InviteSignup.tsx
+++ b/frontend/src/scenes/authentication/invite-signup/InviteSignup.tsx
@@ -1,458 +1,19 @@
-import clsx from 'clsx'
-import { useActions, useValues } from 'kea'
-import { Form } from 'kea-forms'
-import { useEffect } from 'react'
+import { useValues } from 'kea'
-import { IconChevronLeft, IconChevronRight } from '@posthog/icons'
-import { LemonButton, LemonDivider, LemonInput } from '@posthog/lemon-ui'
-
-import { BridgePage } from 'lib/components/BridgePage/BridgePage'
-import PasswordStrength from 'lib/components/PasswordStrength'
-import SignupRoleSelect from 'lib/components/SignupRoleSelect'
-import passkeyLogo from 'lib/components/SocialLoginButton/passkey.svg'
-import { SSOEnforcedLoginButton, SocialLoginButtons } from 'lib/components/SocialLoginButton/SocialLoginButton'
-import { supportLogic } from 'lib/components/Support/supportLogic'
-import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-import { Link } from 'lib/lemon-ui/Link'
-import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
-import { SpinnerOverlay } from 'lib/lemon-ui/Spinner/Spinner'
-import { loginLogic } from 'scenes/authentication/login/loginLogic'
-import { SupportModalButton } from 'scenes/authentication/shared/SupportModalButton'
-import { TurnstileChallenge } from 'scenes/authentication/signup/signupForm/TurnstileChallenge'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { SceneExport } from 'scenes/sceneTypes'
-import { urls } from 'scenes/urls'
-import { userLogic } from 'scenes/userLogic'
-
-import { PrevalidatedInvite } from '~/types'
-import { ErrorCodes, inviteSignupLogic } from './inviteSignupLogic'
+import { authFlowVariantRegistry } from '../authFlowVariantRegistry'
+import { resolveAuthFlowVariant } from '../authFlowVariants'
+import { inviteSignupLogic } from './inviteSignupLogic'
export const scene: SceneExport = {
component: InviteSignup,
logic: inviteSignupLogic,
}
-const UTM_TAGS = 'utm_medium=in-product&utm_campaign=invite-signup'
-
-interface ErrorMessage {
- title: string
- detail: JSX.Element | string
- actions: JSX.Element
-}
-
-function HelperLinks(): JSX.Element {
- return (
- <div className="font-bold text-center">
- <Link to="/">App Home</Link>
- <span className="mx-2">|</span>
- <Link to={`https://posthog.com?${UTM_TAGS}&utm_message=invalid-invite`}>PostHog Website</Link>
- </div>
- )
-}
-
-function BackToPostHog(): JSX.Element {
- return (
- <LemonButton type="secondary" icon={<IconChevronLeft />} center fullWidth to={urls.default()}>
- Go back to PostHog
- </LemonButton>
- )
-}
-
-function ErrorView(): JSX.Element | null {
- const { error } = useValues(inviteSignupLogic)
- const { user } = useValues(userLogic)
-
- const ErrorMessages: Record<ErrorCodes, ErrorMessage> = {
- [ErrorCodes.InvalidInvite]: {
- title: 'Oops! This invite link is invalid or has expired',
- detail: (
- <>
- {error?.detail} If you believe this is a mistake, please contact whoever created this invite and{' '}
- <b>ask them for a new invite</b>.
- </>
- ),
- actions: user ? <BackToPostHog /> : <HelperLinks />,
- },
- [ErrorCodes.UserAlreadyMember]: {
- title: "You're already a member of this organization",
- detail: (
- <>
- {error?.detail || 'You already are a member of this organization.'} You can't accept this invitation
- because your account ({user?.email}) already belongs to it. If you meant to join a different
- organization, ask the inviter to send a new invite to a different email address.
- </>
- ),
- actions: user ? <BackToPostHog /> : <HelperLinks />,
- },
- [ErrorCodes.InvalidRecipient]: {
- title: "Oops! This invite link can't be used",
- detail: (
- <>
- <div>{error?.detail}</div>
- <div className="mt-4">
- {user ? (
- <span>
- You can either log out and create a new account under the new email address or ask the
- organization admin to send a{' '}
- <b>new invite to the email address on your account, {user?.email}</b>.
- </span>
- ) : (
- <div>
- You need to log in with the email address above, or create your own password.
- <div className="mt-4">
- <LemonButton
- icon={<IconChevronLeft />}
- to={window.location.pathname}
- disableClientSideRouting
- >
- Try again
- </LemonButton>
- </div>
- </div>
- )}
- </div>
- </>
- ),
- actions: user ? <BackToPostHog /> : <HelperLinks />,
- },
- [ErrorCodes.Unknown]: {
- title: 'Oops! We could not validate this invite link',
- detail: `${
- error?.detail || ''
- } There was an issue with your invite link, please try again in a few seconds. If the problem persists, contact us.`,
- actions: user ? <BackToPostHog /> : <HelperLinks />,
- },
- }
-
- if (!error) {
- return null
- }
-
- return (
- <BridgePage view="signup-error" hedgehog message="Oops!" footer={<SupportModalButton />}>
- <h2>{ErrorMessages[error.code].title}</h2>
- <div className="error-message">{ErrorMessages[error.code].detail}</div>
- <LemonDivider dashed className="my-4" />
- <div>{ErrorMessages[error.code].actions}</div>
- </BridgePage>
- )
-}
-
-function AuthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite }): JSX.Element {
- const { user } = useValues(userLogic)
- const { acceptInvite } = useActions(inviteSignupLogic)
- const { acceptedInviteLoading, acceptedInvite } = useValues(inviteSignupLogic)
-
- return (
- <BridgePage
- view="accept-invite"
- hedgehog
- message={user?.first_name ? `Hey ${user?.first_name}!` : 'Hello!'}
- footer={<SupportModalButton name={user?.first_name} email={user?.email} />}
- >
- <div className="deprecated-space-y-2">
- <h2>You have been invited to join {invite.organization_name}</h2>
- <div>
- You will accept the invite under your <b>existing PostHog account</b>:
- </div>
- {user && (
- <div
- className="border rounded-lg border-dashed flex items-center gap-2 px-2 py-1"
- data-attr="accept-invite-whoami"
- >
- <ProfilePicture user={user} />
- <div>
- <div className="font-bold">{user.first_name}</div>
- <div>{user.email}</div>
- </div>
- </div>
- )}
- <div>
- Accepting will add <b>{invite.organization_name}</b> to your account. You can switch between
- organizations at any time using the organization selector in the top-left of the navigation bar.
- </div>
- <div>
- {!acceptedInvite ? (
- <>
- <LemonButton
- type="primary"
- center
- fullWidth
- onClick={acceptInvite}
- loading={acceptedInviteLoading}
- >
- Accept invite
- </LemonButton>
- <div className="mt-2">
- <LemonButton type="secondary" center fullWidth icon={<IconChevronLeft />} to="/">
- Go back to PostHog
- </LemonButton>
- </div>
- </>
- ) : (
- <LemonButton
- type="secondary"
- center
- fullWidth
- sideIcon={<IconChevronRight />}
- onClick={() => (window.location.href = '/')}
- >
- Go to PostHog
- </LemonButton>
- )}
- </div>
- </div>
- </BridgePage>
- )
-}
-
-function UnauthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite }): JSX.Element {
- const {
- isSignupSubmitting,
- validatedPassword,
- signupManualErrors,
- passkeyRegistered,
- isPasskeyRegistering,
- passkeyError,
- passkeySignupEnabled,
- challengeRequired,
- turnstileSiteKey,
- turnstileToken,
- } = useValues(inviteSignupLogic)
- const { registerPasskey, setTurnstileToken } = useActions(inviteSignupLogic)
- const { preflight } = useValues(preflightLogic)
- const { openSupportForm } = useActions(supportLogic)
-
- const { precheck } = useActions(loginLogic)
- const { precheckResponse, precheckResponseLoading } = useValues(loginLogic)
-
- const areExtraFieldsHidden = precheckResponse.sso_enforcement
-
- useEffect(() => {
- precheck({ email: invite.target_email })
- }, [invite.target_email]) // oxlint-disable-line react-hooks/exhaustive-deps
-
- return (
- <BridgePage
- view="invites-signup"
- hedgehog
- message={
- <>
- Welcome to
- <br /> PostHog{preflight?.cloud ? ' Cloud' : ''}!
- </>
- }
- leftContainerContent={
- <div className="mb-8 text-secondary">
- <div className="font-semibold flex flex-col gap-2 text-center items-center text-lg">
- <span>You've been invited to join</span>
- <span className="text-4xl font-bold border-b border-dashed pb-2">
- {invite?.organization_name || 'us'}
- </span>
- <span>on PostHog</span>
- </div>
- </div>
- }
- footer={<SupportModalButton name={invite.first_name} email={invite.target_email} />}
- >
- <h2 className="text-center">Create your PostHog account</h2>
- {signupManualErrors?.generic && (
- <LemonBanner type="error" className="mb-4">
- {signupManualErrors.generic.detail || 'Could not complete your signup.'}{' '}
- {preflight?.cloud && (
- <Link
- data-attr="invite-signup-error-contact-support"
- onClick={(e) => {
- e.preventDefault()
- openSupportForm({
- kind: 'support',
- target_area: 'login',
- email: invite.target_email,
- })
- }}
- >
- Need help?
- </Link>
- )}
- </LemonBanner>
- )}
- {passkeyError && (
- <LemonBanner type="error" className="mb-4">
- {passkeyError}
- </LemonBanner>
- )}
- <Form logic={inviteSignupLogic} formKey="signup" className="deprecated-space-y-4" enableFormOnSubmit>
- <LemonField.Pure label="Email">
- <LemonInput type="email" disabled value={invite?.target_email} />
- </LemonField.Pure>
- {!areExtraFieldsHidden && (
- <>
- {passkeySignupEnabled && (
- <>
- {passkeyRegistered ? (
- <div className="bg-surface-secondary rounded-lg p-4 text-center">
- <img src={passkeyLogo} alt="Passkey" className="w-8 h-8 mx-auto mb-2" />
- <p className="font-semibold mb-1">Passkey registered successfully!</p>
- <p className="text-sm text-muted">
- Complete the form below and press "Continue" to create your account.
- </p>
- </div>
- ) : (
- <LemonButton
- fullWidth
- type="secondary"
- center
- size="large"
- icon={
- <img src={passkeyLogo} alt="Passkey" className="object-contain w-7 h-7" />
- }
- onClick={registerPasskey}
- loading={isPasskeyRegistering}
- disabled={isPasskeyRegistering}
- data-attr="invite-signup-passkey"
- >
- Sign up with passkey
- </LemonButton>
- )}
-
- {!passkeyRegistered && (
- <div className="flex items-center gap-3 my-4">
- <div className="flex-1 border-t border-border" />
- <span className="text-secondary text-sm">or use a password</span>
- <div className="flex-1 border-t border-border" />
- </div>
- )}
- </>
- )}
- {!passkeyRegistered && (
- <LemonField
- name="password"
- label={
- <div className="flex flex-1 items-center justify-between">
- <span>Password</span>
- <PasswordStrength validatedPassword={validatedPassword} />
- </div>
- }
- >
- <LemonInput
- type="password"
- className="ph-ignore-input"
- data-attr="password"
- placeholder="••••••••••"
- autoComplete="new-password"
- autoFocus={!passkeySignupEnabled}
- disabled={isSignupSubmitting || passkeyRegistered}
- />
- </LemonField>
- )}
-
- <LemonField
- name="first_name"
- label="First Name"
- help={
- invite?.first_name
- ? 'Your name was provided in the invite, feel free to change it.'
- : undefined
- }
- >
- <LemonInput data-attr="first_name" placeholder="Jane" />
- </LemonField>
-
- <SignupRoleSelect />
- </>
- )}
-
- {/* Show regular login button if SSO is not enforced */}
- {!precheckResponse.sso_enforcement &&
- (challengeRequired && turnstileSiteKey ? (
- <TurnstileChallenge
- siteKey={turnstileSiteKey}
- onSuccess={setTurnstileToken}
- tokenReceived={!!turnstileToken}
- email={invite.target_email}
- />
- ) : (
- <LemonButton
- type="primary"
- status="alt"
- htmlType="submit"
- data-attr="password-signup"
- fullWidth
- center
- loading={isSignupSubmitting || precheckResponseLoading}
- size="large"
- >
- Continue
- </LemonButton>
- ))}
-
- {/* Show enforced SSO button if required */}
- {precheckResponse.sso_enforcement && (
- <SSOEnforcedLoginButton
- provider={precheckResponse.sso_enforcement}
- email={invite?.target_email}
- actionText="Continue"
- extraQueryParams={invite ? { invite_id: invite.id } : undefined}
- />
- )}
-
- {/* Show optional SAML SSO button if available */}
- {precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
- <SSOEnforcedLoginButton
- provider="saml"
- email={invite?.target_email}
- actionText="Continue"
- extraQueryParams={invite ? { invite_id: invite.id } : undefined}
- />
- )}
- </Form>
- <div className="mt-4 text-center text-secondary">
- Already have an account? <Link to="/login">Log in</Link>
- </div>
- <div className="mt-4 text-center text-secondary">
- By clicking continue you agree to our{' '}
- <Link to="https://posthog.com/terms" target="_blank">
- Terms of Service
- </Link>{' '}
- and{' '}
- <Link to="https://posthog.com/privacy" target="_blank">
- Privacy Policy
- </Link>
- .
- </div>
- {!areExtraFieldsHidden && (
- <SocialLoginButtons
- className="mb-4"
- title="Or sign in with"
- caption={`Remember to log in with ${invite?.target_email}`}
- captionLocation="bottom"
- topDivider
- extraQueryParams={invite ? { invite_id: invite.id } : undefined}
- />
- )}
- </BridgePage>
- )
-}
-
export function InviteSignup(): JSX.Element {
- const { invite, inviteLoading } = useValues(inviteSignupLogic)
- const { user } = useValues(userLogic)
-
- if (inviteLoading) {
- return <SpinnerOverlay sceneLevel />
- }
-
- return (
- <div className={clsx('InviteSignup', !!user && 'InviteSignup--authenticated')}>
- <ErrorView />
- {invite &&
- (user ? (
- <AuthenticatedAcceptInvite invite={invite} />
- ) : (
- <UnauthenticatedAcceptInvite invite={invite} />
- ))}
- </div>
- )
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { InviteSignup: VariantInviteSignup } = authFlowVariantRegistry[resolveAuthFlowVariant(featureFlags)]
+ return <VariantInviteSignup />
}
diff --git a/frontend/src/scenes/authentication/invite-signup/variants/legacy/LegacyInviteSignup.tsx b/frontend/src/scenes/authentication/invite-signup/variants/legacy/LegacyInviteSignup.tsx
new file mode 100644
index 000000000000..2b36aaf9f7d3
--- /dev/null
+++ b/frontend/src/scenes/authentication/invite-signup/variants/legacy/LegacyInviteSignup.tsx
@@ -0,0 +1,452 @@
+import clsx from 'clsx'
+import { useActions, useValues } from 'kea'
+import { Form } from 'kea-forms'
+import { useEffect } from 'react'
+
+import { IconChevronLeft, IconChevronRight } from '@posthog/icons'
+import { LemonButton, LemonDivider, LemonInput } from '@posthog/lemon-ui'
+
+import { BridgePage } from 'lib/components/BridgePage/BridgePage'
+import PasswordStrength from 'lib/components/PasswordStrength'
+import SignupRoleSelect from 'lib/components/SignupRoleSelect'
+import passkeyLogo from 'lib/components/SocialLoginButton/passkey.svg'
+import { SSOEnforcedLoginButton, SocialLoginButtons } from 'lib/components/SocialLoginButton/SocialLoginButton'
+import { supportLogic } from 'lib/components/Support/supportLogic'
+import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+import { Link } from 'lib/lemon-ui/Link'
+import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
+import { SpinnerOverlay } from 'lib/lemon-ui/Spinner/Spinner'
+import { loginLogic } from 'scenes/authentication/login/loginLogic'
+import { SupportModalButton } from 'scenes/authentication/shared/SupportModalButton'
+import { TurnstileChallenge } from 'scenes/authentication/signup/signupForm/TurnstileChallenge'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { urls } from 'scenes/urls'
+import { userLogic } from 'scenes/userLogic'
+
+import { PrevalidatedInvite } from '~/types'
+
+import { ErrorCodes, inviteSignupLogic } from '../../inviteSignupLogic'
+
+const UTM_TAGS = 'utm_medium=in-product&utm_campaign=invite-signup'
+
+interface ErrorMessage {
+ title: string
+ detail: JSX.Element | string
+ actions: JSX.Element
+}
+
+function HelperLinks(): JSX.Element {
+ return (
+ <div className="font-bold text-center">
+ <Link to="/">App Home</Link>
+ <span className="mx-2">|</span>
+ <Link to={`https://posthog.com?${UTM_TAGS}&utm_message=invalid-invite`}>PostHog Website</Link>
+ </div>
+ )
+}
+
+function BackToPostHog(): JSX.Element {
+ return (
+ <LemonButton type="secondary" icon={<IconChevronLeft />} center fullWidth to={urls.default()}>
+ Go back to PostHog
+ </LemonButton>
+ )
+}
+
+function ErrorView(): JSX.Element | null {
+ const { error } = useValues(inviteSignupLogic)
+ const { user } = useValues(userLogic)
+
+ const ErrorMessages: Record<ErrorCodes, ErrorMessage> = {
+ [ErrorCodes.InvalidInvite]: {
+ title: 'Oops! This invite link is invalid or has expired',
+ detail: (
+ <>
+ {error?.detail} If you believe this is a mistake, please contact whoever created this invite and{' '}
+ <b>ask them for a new invite</b>.
+ </>
+ ),
+ actions: user ? <BackToPostHog /> : <HelperLinks />,
+ },
+ [ErrorCodes.UserAlreadyMember]: {
+ title: "You're already a member of this organization",
+ detail: (
+ <>
+ {error?.detail || 'You already are a member of this organization.'} You can't accept this invitation
+ because your account ({user?.email}) already belongs to it. If you meant to join a different
+ organization, ask the inviter to send a new invite to a different email address.
+ </>
+ ),
+ actions: user ? <BackToPostHog /> : <HelperLinks />,
+ },
+ [ErrorCodes.InvalidRecipient]: {
+ title: "Oops! This invite link can't be used",
+ detail: (
+ <>
+ <div>{error?.detail}</div>
+ <div className="mt-4">
+ {user ? (
+ <span>
+ You can either log out and create a new account under the new email address or ask the
+ organization admin to send a{' '}
+ <b>new invite to the email address on your account, {user?.email}</b>.
+ </span>
+ ) : (
+ <div>
+ You need to log in with the email address above, or create your own password.
+ <div className="mt-4">
+ <LemonButton
+ icon={<IconChevronLeft />}
+ to={window.location.pathname}
+ disableClientSideRouting
+ >
+ Try again
+ </LemonButton>
+ </div>
+ </div>
+ )}
+ </div>
+ </>
+ ),
+ actions: user ? <BackToPostHog /> : <HelperLinks />,
+ },
+ [ErrorCodes.Unknown]: {
+ title: 'Oops! We could not validate this invite link',
+ detail: `${
+ error?.detail || ''
+ } There was an issue with your invite link, please try again in a few seconds. If the problem persists, contact us.`,
+ actions: user ? <BackToPostHog /> : <HelperLinks />,
+ },
+ }
+
+ if (!error) {
+ return null
+ }
+
+ return (
+ <BridgePage view="signup-error" hedgehog message="Oops!" footer={<SupportModalButton />}>
+ <h2>{ErrorMessages[error.code].title}</h2>
+ <div className="error-message">{ErrorMessages[error.code].detail}</div>
+ <LemonDivider dashed className="my-4" />
+ <div>{ErrorMessages[error.code].actions}</div>
+ </BridgePage>
+ )
+}
+
+function AuthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite }): JSX.Element {
+ const { user } = useValues(userLogic)
+ const { acceptInvite } = useActions(inviteSignupLogic)
+ const { acceptedInviteLoading, acceptedInvite } = useValues(inviteSignupLogic)
+
+ return (
+ <BridgePage
+ view="accept-invite"
+ hedgehog
+ message={user?.first_name ? `Hey ${user?.first_name}!` : 'Hello!'}
+ footer={<SupportModalButton name={user?.first_name} email={user?.email} />}
+ >
+ <div className="deprecated-space-y-2">
+ <h2>You have been invited to join {invite.organization_name}</h2>
+ <div>
+ You will accept the invite under your <b>existing PostHog account</b>:
+ </div>
+ {user && (
+ <div
+ className="border rounded-lg border-dashed flex items-center gap-2 px-2 py-1"
+ data-attr="accept-invite-whoami"
+ >
+ <ProfilePicture user={user} />
+ <div>
+ <div className="font-bold">{user.first_name}</div>
+ <div>{user.email}</div>
+ </div>
+ </div>
+ )}
+ <div>
+ Accepting will add <b>{invite.organization_name}</b> to your account. You can switch between
+ organizations at any time using the organization selector in the top-left of the navigation bar.
+ </div>
+ <div>
+ {!acceptedInvite ? (
+ <>
+ <LemonButton
+ type="primary"
+ center
+ fullWidth
+ onClick={acceptInvite}
+ loading={acceptedInviteLoading}
+ >
+ Accept invite
+ </LemonButton>
+ <div className="mt-2">
+ <LemonButton type="secondary" center fullWidth icon={<IconChevronLeft />} to="/">
+ Go back to PostHog
+ </LemonButton>
+ </div>
+ </>
+ ) : (
+ <LemonButton
+ type="secondary"
+ center
+ fullWidth
+ sideIcon={<IconChevronRight />}
+ onClick={() => (window.location.href = '/')}
+ >
+ Go to PostHog
+ </LemonButton>
+ )}
+ </div>
+ </div>
+ </BridgePage>
+ )
+}
+
+function UnauthenticatedAcceptInvite({ invite }: { invite: PrevalidatedInvite }): JSX.Element {
+ const {
+ isSignupSubmitting,
+ validatedPassword,
+ signupManualErrors,
+ passkeyRegistered,
+ isPasskeyRegistering,
+ passkeyError,
+ passkeySignupEnabled,
+ challengeRequired,
+ turnstileSiteKey,
+ turnstileToken,
+ } = useValues(inviteSignupLogic)
+ const { registerPasskey, setTurnstileToken } = useActions(inviteSignupLogic)
+ const { preflight } = useValues(preflightLogic)
+ const { openSupportForm } = useActions(supportLogic)
+
+ const { precheck } = useActions(loginLogic)
+ const { precheckResponse, precheckResponseLoading } = useValues(loginLogic)
+
+ const areExtraFieldsHidden = precheckResponse.sso_enforcement
+
+ useEffect(() => {
+ precheck({ email: invite.target_email })
+ }, [invite.target_email]) // oxlint-disable-line react-hooks/exhaustive-deps
+
+ return (
+ <BridgePage
+ view="invites-signup"
+ hedgehog
+ message={
+ <>
+ Welcome to
+ <br /> PostHog{preflight?.cloud ? ' Cloud' : ''}!
+ </>
+ }
+ leftContainerContent={
+ <div className="mb-8 text-secondary">
+ <div className="font-semibold flex flex-col gap-2 text-center items-center text-lg">
+ <span>You've been invited to join</span>
+ <span className="text-4xl font-bold border-b border-dashed pb-2">
+ {invite?.organization_name || 'us'}
+ </span>
+ <span>on PostHog</span>
+ </div>
+ </div>
+ }
+ footer={<SupportModalButton name={invite.first_name} email={invite.target_email} />}
+ >
+ <h2 className="text-center">Create your PostHog account</h2>
+ {signupManualErrors?.generic && (
+ <LemonBanner type="error" className="mb-4">
+ {signupManualErrors.generic.detail || 'Could not complete your signup.'}{' '}
+ {preflight?.cloud && (
+ <Link
+ data-attr="invite-signup-error-contact-support"
+ onClick={(e) => {
+ e.preventDefault()
+ openSupportForm({
+ kind: 'support',
+ target_area: 'login',
+ email: invite.target_email,
+ })
+ }}
+ >
+ Need help?
+ </Link>
+ )}
+ </LemonBanner>
+ )}
+ {passkeyError && (
+ <LemonBanner type="error" className="mb-4">
+ {passkeyError}
+ </LemonBanner>
+ )}
+ <Form logic={inviteSignupLogic} formKey="signup" className="deprecated-space-y-4" enableFormOnSubmit>
+ <LemonField.Pure label="Email">
+ <LemonInput type="email" disabled value={invite?.target_email} />
+ </LemonField.Pure>
+ {!areExtraFieldsHidden && (
+ <>
+ {passkeySignupEnabled && (
+ <>
+ {passkeyRegistered ? (
+ <div className="bg-surface-secondary rounded-lg p-4 text-center">
+ <img src={passkeyLogo} alt="Passkey" className="w-8 h-8 mx-auto mb-2" />
+ <p className="font-semibold mb-1">Passkey registered successfully!</p>
+ <p className="text-sm text-muted">
+ Complete the form below and press "Continue" to create your account.
+ </p>
+ </div>
+ ) : (
+ <LemonButton
+ fullWidth
+ type="secondary"
+ center
+ size="large"
+ icon={
+ <img src={passkeyLogo} alt="Passkey" className="object-contain w-7 h-7" />
+ }
+ onClick={registerPasskey}
+ loading={isPasskeyRegistering}
+ disabled={isPasskeyRegistering}
+ data-attr="invite-signup-passkey"
+ >
+ Sign up with passkey
+ </LemonButton>
+ )}
+
+ {!passkeyRegistered && (
+ <div className="flex items-center gap-3 my-4">
+ <div className="flex-1 border-t border-border" />
+ <span className="text-secondary text-sm">or use a password</span>
+ <div className="flex-1 border-t border-border" />
+ </div>
+ )}
+ </>
+ )}
+ {!passkeyRegistered && (
+ <LemonField
+ name="password"
+ label={
+ <div className="flex flex-1 items-center justify-between">
+ <span>Password</span>
+ <PasswordStrength validatedPassword={validatedPassword} />
+ </div>
+ }
+ >
+ <LemonInput
+ type="password"
+ className="ph-ignore-input"
+ data-attr="password"
+ placeholder="••••••••••"
+ autoComplete="new-password"
+ autoFocus={!passkeySignupEnabled}
+ disabled={isSignupSubmitting || passkeyRegistered}
+ />
+ </LemonField>
+ )}
+
+ <LemonField
+ name="first_name"
+ label="First Name"
+ help={
+ invite?.first_name
+ ? 'Your name was provided in the invite, feel free to change it.'
+ : undefined
+ }
+ >
+ <LemonInput data-attr="first_name" placeholder="Jane" />
+ </LemonField>
+
+ <SignupRoleSelect />
+ </>
+ )}
+
+ {/* Show regular login button if SSO is not enforced */}
+ {!precheckResponse.sso_enforcement &&
+ (challengeRequired && turnstileSiteKey ? (
+ <TurnstileChallenge
+ siteKey={turnstileSiteKey}
+ onSuccess={setTurnstileToken}
+ tokenReceived={!!turnstileToken}
+ email={invite.target_email}
+ />
+ ) : (
+ <LemonButton
+ type="primary"
+ status="alt"
+ htmlType="submit"
+ data-attr="password-signup"
+ fullWidth
+ center
+ loading={isSignupSubmitting || precheckResponseLoading}
+ size="large"
+ >
+ Continue
+ </LemonButton>
+ ))}
+
+ {/* Show enforced SSO button if required */}
+ {precheckResponse.sso_enforcement && (
+ <SSOEnforcedLoginButton
+ provider={precheckResponse.sso_enforcement}
+ email={invite?.target_email}
+ actionText="Continue"
+ extraQueryParams={invite ? { invite_id: invite.id } : undefined}
+ />
+ )}
+
+ {/* Show optional SAML SSO button if available */}
+ {precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
+ <SSOEnforcedLoginButton
+ provider="saml"
+ email={invite?.target_email}
+ actionText="Continue"
+ extraQueryParams={invite ? { invite_id: invite.id } : undefined}
+ />
+ )}
+ </Form>
+ <div className="mt-4 text-center text-secondary">
+ Already have an account? <Link to="/login">Log in</Link>
+ </div>
+ <div className="mt-4 text-center text-secondary">
+ By clicking continue you agree to our{' '}
+ <Link to="https://posthog.com/terms" target="_blank">
+ Terms of Service
+ </Link>{' '}
+ and{' '}
+ <Link to="https://posthog.com/privacy" target="_blank">
+ Privacy Policy
+ </Link>
+ .
+ </div>
+ {!areExtraFieldsHidden && (
+ <SocialLoginButtons
+ className="mb-4"
+ title="Or sign in with"
+ caption={`Remember to log in with ${invite?.target_email}`}
+ captionLocation="bottom"
+ topDivider
+ extraQueryParams={invite ? { invite_id: invite.id } : undefined}
+ />
+ )}
+ </BridgePage>
+ )
+}
+
+export function LegacyInviteSignup(): JSX.Element {
+ const { invite, inviteLoading } = useValues(inviteSignupLogic)
+ const { user } = useValues(userLogic)
+
+ if (inviteLoading) {
+ return <SpinnerOverlay sceneLevel />
+ }
+
+ return (
+ <div className={clsx('InviteSignup', !!user && 'InviteSignup--authenticated')}>
+ <ErrorView />
+ {invite &&
+ (user ? (
+ <AuthenticatedAcceptInvite invite={invite} />
+ ) : (
+ <UnauthenticatedAcceptInvite invite={invite} />
+ ))}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/authentication/invite-signup/variants/redesign-2026-06-02/InviteSignupV2.tsx b/frontend/src/scenes/authentication/invite-signup/variants/redesign-2026-06-02/InviteSignupV2.tsx
new file mode 100644
index 000000000000..6a20728df578
--- /dev/null
+++ b/frontend/src/scenes/authentication/invite-signup/variants/redesign-2026-06-02/InviteSignupV2.tsx
@@ -0,0 +1,13 @@
+import { BridgePage } from 'lib/components/BridgePage/BridgePage'
+
+// TODO: build the redesign-2026-06-02 invited signup; renders under the `auth-flow-variant` flag.
+export function InviteSignupV2(): JSX.Element {
+ return (
+ <BridgePage view="invites-signup" hedgehog message="You're invited">
+ <div className="deprecated-space-y-4">
+ <h2>Create your account</h2>
+ <p className="text-secondary">Redesigned invited signup — coming soon.</p>
+ </div>
+ </BridgePage>
+ )
+}
diff --git a/frontend/src/scenes/authentication/login/Login.tsx b/frontend/src/scenes/authentication/login/Login.tsx
index d9a20cbb5f0b..90b5c199f156 100644
--- a/frontend/src/scenes/authentication/login/Login.tsx
+++ b/frontend/src/scenes/authentication/login/Login.tsx
@@ -1,71 +1,14 @@
-import './Login.scss'
+import { useValues } from 'kea'
-import clsx from 'clsx'
-import { useActions, useValues } from 'kea'
-import { Form } from 'kea-forms'
-import { useEffect, useRef } from 'react'
-
-import { LemonButton, LemonInput, LemonTag } from '@posthog/lemon-ui'
-
-import { getCookie } from 'lib/api'
-import { SSOEnforcedLoginButton, SocialLoginButtons } from 'lib/components/SocialLoginButton/SocialLoginButton'
-import { supportLogic } from 'lib/components/Support/supportLogic'
-import { usePrevious } from 'lib/hooks/usePrevious'
-import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-import { Link } from 'lib/lemon-ui/Link'
-import { Skeleton } from 'lib/ui/quill'
-import { isEmail } from 'lib/utils'
-import { AuthShell } from 'scenes/authentication/shared/AuthShell'
-import { RedirectIfLoggedInOtherInstance } from 'scenes/authentication/shared/RedirectToLoggedInInstance'
-import RegionSelect from 'scenes/authentication/shared/RegionSelect'
-import { SupportModalButton } from 'scenes/authentication/shared/SupportModalButton'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { SceneExport } from 'scenes/sceneTypes'
-import { urls } from 'scenes/urls'
-
-import { LoginMethod } from '~/types'
+import { authFlowVariantRegistry } from '../authFlowVariantRegistry'
+import { resolveAuthFlowVariant } from '../authFlowVariants'
import { loginLogic } from './loginLogic'
-export const ERROR_MESSAGES: Record<string, string | JSX.Element> = {
- no_new_organizations:
- 'Your email address is not associated with an account. Please ask your administrator for an invite.',
- invalid_sso_provider: (
- <>
- The SSO provider you specified is invalid. Visit{' '}
- <Link to="https://posthog.com/sso" target="_blank">
- https://posthog.com/sso
- </Link>{' '}
- for details.
- </>
- ),
- improperly_configured_sso: (
- <>
- Cannot login with SSO provider because the provider is not configured, or your instance does not have the
- required license. Please visit{' '}
- <Link to="https://posthog.com/sso" target="_blank">
- https://posthog.com/sso
- </Link>{' '}
- for details.
- </>
- ),
- jit_not_enabled:
- 'We could not find an account with your email address and your organization does not support automatic enrollment. Please contact your administrator for an invite.',
- saml_sso_enforced:
- 'Your organization requires SAML SSO authentication. Please enter your email address to access your account.',
- google_sso_enforced: 'Your organization does not allow this authentication method. Please log in with Google.',
- github_sso_enforced: 'Your organization does not allow this authentication method. Please log in with GitHub.',
- gitlab_sso_enforced: 'Your organization does not allow this authentication method. Please log in with GitLab.',
- // our catch-all case, so the message is generic
- sso_enforced: "Please log in with your organization's required SSO method.",
- oauth_cancelled: "Sign in was cancelled. Please try again when you're ready.",
- invalid_invite:
- 'This invite link is no longer valid. It may have expired or been revoked. Please ask your administrator for a new invite.',
- social_login_failure: 'Login failed. Please try again or contact your administrator.',
-}
-
-const LAST_LOGIN_METHOD_COOKIE = 'ph_last_login_method'
+// ExporterLogin imports ERROR_MESSAGES from this module path.
+export { ERROR_MESSAGES } from './variants/legacy/LegacyLogin'
export const scene: SceneExport = {
component: Login,
@@ -73,281 +16,7 @@ export const scene: SceneExport = {
}
export function Login(): JSX.Element {
- const { precheck, resendEmailMFA, clearGeneralError, resetLogin, devLogin, loadDevUsers } = useActions(loginLogic)
- const { openSupportForm } = useActions(supportLogic)
- const {
- precheckResponse,
- precheckResponseLoading,
- login,
- isLoginSubmitting,
- generalError,
- signupUrl,
- resendResponseLoading,
- devUsers,
- devUsersLoading,
- devLoginTimeSavedLabel,
- } = useValues(loginLogic)
- const { preflight } = useValues(preflightLogic)
- const allowDevLogin = !!preflight?.allow_dev_login
-
- useEffect(() => {
- if (allowDevLogin) {
- loadDevUsers(null)
- }
- }, [allowDevLogin, loadDevUsers])
-
- const passwordInputRef = useRef<HTMLInputElement>(null)
- const preventPasswordError = useRef(false)
- const isPasswordHidden = precheckResponse.status === 'pending' || precheckResponse.sso_enforcement
- const isEmailVerificationSent = generalError?.code === 'email_verification_sent'
- const loginTitle = isEmailVerificationSent ? 'Check your email' : 'Log in'
- const wasPasswordHiddenRef = useRef(isPasswordHidden)
-
- const lastLoginMethod = getCookie(LAST_LOGIN_METHOD_COOKIE) as LoginMethod
- const prevEmail = usePrevious(login.email)
-
- useEffect(() => {
- const wasPasswordHidden = wasPasswordHiddenRef.current
- wasPasswordHiddenRef.current = isPasswordHidden
-
- if (!isPasswordHidden) {
- passwordInputRef.current?.focus()
- } else if (!wasPasswordHidden) {
- // clear form when transitioning from visible to hidden
- resetLogin()
- }
- }, [isPasswordHidden, resetLogin])
-
- // Trigger precheck for password manager autofill/paste (detected by large character delta)
- useEffect(() => {
- const charDelta = login.email.length - (prevEmail?.length ?? 0)
- const isAutofill = charDelta > 1
-
- if (isAutofill && isEmail(login.email, { requireTLD: true }) && precheckResponse.status === 'pending') {
- precheck({ email: login.email })
- }
- }, [login.email, prevEmail, precheckResponse.status, precheck])
-
- return (
- <AuthShell
- view="login"
- showHedgehog
- message={
- <>
- Welcome to
- <br /> PostHog{preflight?.cloud ? ' Cloud' : ''}!
- </>
- }
- footer={<SupportModalButton />}
- >
- {preflight?.cloud && <RedirectIfLoggedInOtherInstance />}
- <div className="deprecated-space-y-4">
- <h2>{loginTitle}</h2>
- {generalError && (
- <LemonBanner type={generalError.code === 'email_verification_sent' ? 'warning' : 'error'}>
- <>
- {generalError.detail || ERROR_MESSAGES[generalError.code] || (
- <>
- Could not complete your login.
- <br />
- Please try again.
- </>
- )}
- {preflight?.cloud && (
- <>
- {' '}
- <Link
- data-attr="login-error-contact-support"
- onClick={(e) => {
- e.preventDefault()
- openSupportForm({
- kind: 'support',
- target_area: 'login',
- email: login.email,
- })
- }}
- >
- Need help?
- </Link>
- </>
- )}
- </>
- </LemonBanner>
- )}
- {isEmailVerificationSent ? (
- <div className="deprecated-space-y-4">
- <div className="flex justify-center">
- <LemonButton
- type="tertiary"
- size="small"
- loading={resendResponseLoading}
- onClick={() => resendEmailMFA(null)}
- >
- Resend verification email
- </LemonButton>
- </div>
- <div className="text-center">
- <Link onClick={() => clearGeneralError()} className="text-muted">
- Back to login
- </Link>
- </div>
- </div>
- ) : (
- <Form
- logic={loginLogic}
- formKey="login"
- enableFormOnSubmit
- onSubmitCapture={(e) => {
- if (isPasswordHidden || preventPasswordError.current) {
- e.preventDefault()
- e.stopPropagation()
- preventPasswordError.current = false
- }
- }}
- className="deprecated-space-y-4"
- >
- <RegionSelect />
- <LemonField name="email" label="Email">
- <LemonInput
- className="ph-ignore-input"
- autoFocus
- data-attr="login-email"
- placeholder="[email protected]"
- type="email"
- onBlur={() => precheck({ email: login.email })}
- onPressEnter={(e) => {
- if (isPasswordHidden) {
- e.preventDefault() // Don't trigger submission if password field is still hidden
- passwordInputRef.current?.focus()
- }
- }}
- badgeText={lastLoginMethod === 'password' ? 'Last used' : undefined}
- />
- </LemonField>
- <div className={clsx('PasswordWrapper', isPasswordHidden && 'zero-height')}>
- <LemonField
- name="password"
- label={
- <div className="flex flex-1 items-center justify-between gap-2">
- <span>Password</span>
- <Link
- to={[urls.passwordReset(), { email: login.email }]}
- data-attr="forgot-password"
- tabIndex={-1}
- >
- Forgot your password?
- </Link>
- </div>
- }
- >
- <LemonInput
- type="password"
- inputRef={passwordInputRef}
- className="ph-ignore-input"
- data-attr="password"
- placeholder="••••••••••"
- autoComplete="current-password"
- />
- </LemonField>
- </div>
-
- {/* Show regular login button if SSO is not enforced */}
- {!precheckResponse.sso_enforcement && (
- <LemonButton
- type="primary"
- status="alt"
- htmlType="submit"
- data-attr="password-login"
- fullWidth
- center
- loading={isLoginSubmitting || precheckResponseLoading}
- size="large"
- onMouseDown={() => {
- if (isPasswordHidden) {
- // prevent empty password error
- preventPasswordError.current = true
- }
- }}
- >
- Log in
- </LemonButton>
- )}
-
- {/* Show enforced SSO button if required */}
- {precheckResponse.sso_enforcement && (
- <SSOEnforcedLoginButton
- provider={precheckResponse.sso_enforcement}
- email={login.email}
- isLastUsed={lastLoginMethod === precheckResponse.sso_enforcement}
- />
- )}
-
- {/* Show optional SAML SSO button if available */}
- {precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
- <SSOEnforcedLoginButton
- provider="saml"
- email={login.email}
- isLastUsed={lastLoginMethod === 'saml'}
- />
- )}
- </Form>
- )}
- {!isEmailVerificationSent && preflight?.cloud && (
- <div className="text-center mt-4">
- Don't have an account?{' '}
- <Link to={[signupUrl, { email: login.email }]} data-attr="signup" className="font-bold">
- Create an account
- </Link>
- </div>
- )}
- {!isEmailVerificationSent && !precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
- <SocialLoginButtons
- caption="Or log in with"
- topDivider
- lastUsedProvider={lastLoginMethod}
- showPasskey
- />
- )}
- {allowDevLogin && (
- <div className="deprecated-space-y-2 border-t border-dashed pt-4 mt-4">
- <div className="flex items-center justify-between">
- <h4 className="m-0">Dev login</h4>
- </div>
- <p className="text-muted text-sm m-0">
- Click a user to log in without a password. This list is only exposed in development mode.
- </p>
- {!devUsersLoading && devLoginTimeSavedLabel && (
- <p className="text-muted text-sm m-0">{devLoginTimeSavedLabel}</p>
- )}
- {devUsersLoading && <Skeleton className="w-full h-10" />}
- <div className="deprecated-space-y-1">
- {devUsers.map((u) => (
- <LemonButton
- key={u.email}
- type="secondary"
- fullWidth
- data-attr={`dev-login-${u.email}`}
- onClick={() => devLogin(u.email)}
- >
- <span className="flex items-center gap-2 w-full">
- <span className="flex-1 text-left truncate">{u.email}</span>
- {u.label && (
- <LemonTag type="success" size="small">
- {u.label}
- </LemonTag>
- )}
- {u.is_staff && !u.label && (
- <LemonTag type="default" size="small">
- Staff
- </LemonTag>
- )}
- </span>
- </LemonButton>
- ))}
- </div>
- </div>
- )}
- </div>
- </AuthShell>
- )
+ const { featureFlags } = useValues(featureFlagLogic)
+ const { Login: VariantLogin } = authFlowVariantRegistry[resolveAuthFlowVariant(featureFlags)]
+ return <VariantLogin />
}
diff --git a/frontend/src/scenes/authentication/login/variants/legacy/LegacyLogin.tsx b/frontend/src/scenes/authentication/login/variants/legacy/LegacyLogin.tsx
new file mode 100644
index 000000000000..c71ccde539ca
--- /dev/null
+++ b/frontend/src/scenes/authentication/login/variants/legacy/LegacyLogin.tsx
@@ -0,0 +1,347 @@
+import '../../Login.scss'
+
+import clsx from 'clsx'
+import { useActions, useValues } from 'kea'
+import { Form } from 'kea-forms'
+import { useEffect, useRef } from 'react'
+
+import { LemonButton, LemonInput, LemonTag } from '@posthog/lemon-ui'
+
+import { getCookie } from 'lib/api'
+import { SSOEnforcedLoginButton, SocialLoginButtons } from 'lib/components/SocialLoginButton/SocialLoginButton'
+import { supportLogic } from 'lib/components/Support/supportLogic'
+import { usePrevious } from 'lib/hooks/usePrevious'
+import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+import { Link } from 'lib/lemon-ui/Link'
+import { Skeleton } from 'lib/ui/quill'
+import { isEmail } from 'lib/utils'
+import { AuthShell } from 'scenes/authentication/shared/AuthShell'
+import { RedirectIfLoggedInOtherInstance } from 'scenes/authentication/shared/RedirectToLoggedInInstance'
+import RegionSelect from 'scenes/authentication/shared/RegionSelect'
+import { SupportModalButton } from 'scenes/authentication/shared/SupportModalButton'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { urls } from 'scenes/urls'
+
+import { LoginMethod } from '~/types'
+
+import { loginLogic } from '../../loginLogic'
+
+export const ERROR_MESSAGES: Record<string, string | JSX.Element> = {
+ no_new_organizations:
+ 'Your email address is not associated with an account. Please ask your administrator for an invite.',
+ invalid_sso_provider: (
+ <>
+ The SSO provider you specified is invalid. Visit{' '}
+ <Link to="https://posthog.com/sso" target="_blank">
+ https://posthog.com/sso
+ </Link>{' '}
+ for details.
+ </>
+ ),
+ improperly_configured_sso: (
+ <>
+ Cannot login with SSO provider because the provider is not configured, or your instance does not have the
+ required license. Please visit{' '}
+ <Link to="https://posthog.com/sso" target="_blank">
+ https://posthog.com/sso
+ </Link>{' '}
+ for details.
+ </>
+ ),
+ jit_not_enabled:
+ 'We could not find an account with your email address and your organization does not support automatic enrollment. Please contact your administrator for an invite.',
+ saml_sso_enforced:
+ 'Your organization requires SAML SSO authentication. Please enter your email address to access your account.',
+ google_sso_enforced: 'Your organization does not allow this authentication method. Please log in with Google.',
+ github_sso_enforced: 'Your organization does not allow this authentication method. Please log in with GitHub.',
+ gitlab_sso_enforced: 'Your organization does not allow this authentication method. Please log in with GitLab.',
+ // our catch-all case, so the message is generic
+ sso_enforced: "Please log in with your organization's required SSO method.",
+ oauth_cancelled: "Sign in was cancelled. Please try again when you're ready.",
+ invalid_invite:
+ 'This invite link is no longer valid. It may have expired or been revoked. Please ask your administrator for a new invite.',
+ social_login_failure: 'Login failed. Please try again or contact your administrator.',
+}
+
+const LAST_LOGIN_METHOD_COOKIE = 'ph_last_login_method'
+
+export function LegacyLogin(): JSX.Element {
+ const { precheck, resendEmailMFA, clearGeneralError, resetLogin, devLogin, loadDevUsers } = useActions(loginLogic)
+ const { openSupportForm } = useActions(supportLogic)
+ const {
+ precheckResponse,
+ precheckResponseLoading,
+ login,
+ isLoginSubmitting,
+ generalError,
+ signupUrl,
+ resendResponseLoading,
+ devUsers,
+ devUsersLoading,
+ devLoginTimeSavedLabel,
+ } = useValues(loginLogic)
+ const { preflight } = useValues(preflightLogic)
+ const allowDevLogin = !!preflight?.allow_dev_login
+
+ useEffect(() => {
+ if (allowDevLogin) {
+ loadDevUsers(null)
+ }
+ }, [allowDevLogin, loadDevUsers])
+
+ const passwordInputRef = useRef<HTMLInputElement>(null)
+ const preventPasswordError = useRef(false)
+ const isPasswordHidden = precheckResponse.status === 'pending' || precheckResponse.sso_enforcement
+ const isEmailVerificationSent = generalError?.code === 'email_verification_sent'
+ const loginTitle = isEmailVerificationSent ? 'Check your email' : 'Log in'
+ const wasPasswordHiddenRef = useRef(isPasswordHidden)
+
+ const lastLoginMethod = getCookie(LAST_LOGIN_METHOD_COOKIE) as LoginMethod
+ const prevEmail = usePrevious(login.email)
+
+ useEffect(() => {
+ const wasPasswordHidden = wasPasswordHiddenRef.current
+ wasPasswordHiddenRef.current = isPasswordHidden
+
+ if (!isPasswordHidden) {
+ passwordInputRef.current?.focus()
+ } else if (!wasPasswordHidden) {
+ // clear form when transitioning from visible to hidden
+ resetLogin()
+ }
+ }, [isPasswordHidden, resetLogin])
+
+ // Trigger precheck for password manager autofill/paste (detected by large character delta)
+ useEffect(() => {
+ const charDelta = login.email.length - (prevEmail?.length ?? 0)
+ const isAutofill = charDelta > 1
+
+ if (isAutofill && isEmail(login.email, { requireTLD: true }) && precheckResponse.status === 'pending') {
+ precheck({ email: login.email })
+ }
+ }, [login.email, prevEmail, precheckResponse.status, precheck])
+
+ return (
+ <AuthShell
+ view="login"
+ showHedgehog
+ message={
+ <>
+ Welcome to
+ <br /> PostHog{preflight?.cloud ? ' Cloud' : ''}!
+ </>
+ }
+ footer={<SupportModalButton />}
+ >
+ {preflight?.cloud && <RedirectIfLoggedInOtherInstance />}
+ <div className="deprecated-space-y-4">
+ <h2>{loginTitle}</h2>
+ {generalError && (
+ <LemonBanner type={generalError.code === 'email_verification_sent' ? 'warning' : 'error'}>
+ <>
+ {generalError.detail || ERROR_MESSAGES[generalError.code] || (
+ <>
+ Could not complete your login.
+ <br />
+ Please try again.
+ </>
+ )}
+ {preflight?.cloud && (
+ <>
+ {' '}
+ <Link
+ data-attr="login-error-contact-support"
+ onClick={(e) => {
+ e.preventDefault()
+ openSupportForm({
+ kind: 'support',
+ target_area: 'login',
+ email: login.email,
+ })
+ }}
+ >
+ Need help?
+ </Link>
+ </>
+ )}
+ </>
+ </LemonBanner>
+ )}
+ {isEmailVerificationSent ? (
+ <div className="deprecated-space-y-4">
+ <div className="flex justify-center">
+ <LemonButton
+ type="tertiary"
+ size="small"
+ loading={resendResponseLoading}
+ onClick={() => resendEmailMFA(null)}
+ >
+ Resend verification email
+ </LemonButton>
+ </div>
+ <div className="text-center">
+ <Link onClick={() => clearGeneralError()} className="text-muted">
+ Back to login
+ </Link>
+ </div>
+ </div>
+ ) : (
+ <Form
+ logic={loginLogic}
+ formKey="login"
+ enableFormOnSubmit
+ onSubmitCapture={(e) => {
+ if (isPasswordHidden || preventPasswordError.current) {
+ e.preventDefault()
+ e.stopPropagation()
+ preventPasswordError.current = false
+ }
+ }}
+ className="deprecated-space-y-4"
+ >
+ <RegionSelect />
+ <LemonField name="email" label="Email">
+ <LemonInput
+ className="ph-ignore-input"
+ autoFocus
+ data-attr="login-email"
+ placeholder="[email protected]"
+ type="email"
+ onBlur={() => precheck({ email: login.email })}
+ onPressEnter={(e) => {
+ if (isPasswordHidden) {
+ e.preventDefault() // Don't trigger submission if password field is still hidden
+ passwordInputRef.current?.focus()
+ }
+ }}
+ badgeText={lastLoginMethod === 'password' ? 'Last used' : undefined}
+ />
+ </LemonField>
+ <div className={clsx('PasswordWrapper', isPasswordHidden && 'zero-height')}>
+ <LemonField
+ name="password"
+ label={
+ <div className="flex flex-1 items-center justify-between gap-2">
+ <span>Password</span>
+ <Link
+ to={[urls.passwordReset(), { email: login.email }]}
+ data-attr="forgot-password"
+ tabIndex={-1}
+ >
+ Forgot your password?
+ </Link>
+ </div>
+ }
+ >
+ <LemonInput
+ type="password"
+ inputRef={passwordInputRef}
+ className="ph-ignore-input"
+ data-attr="password"
+ placeholder="••••••••••"
+ autoComplete="current-password"
+ />
+ </LemonField>
+ </div>
+
+ {/* Show regular login button if SSO is not enforced */}
+ {!precheckResponse.sso_enforcement && (
+ <LemonButton
+ type="primary"
+ status="alt"
+ htmlType="submit"
+ data-attr="password-login"
+ fullWidth
+ center
+ loading={isLoginSubmitting || precheckResponseLoading}
+ size="large"
+ onMouseDown={() => {
+ if (isPasswordHidden) {
+ // prevent empty password error
+ preventPasswordError.current = true
+ }
+ }}
+ >
+ Log in
+ </LemonButton>
+ )}
+
+ {/* Show enforced SSO button if required */}
+ {precheckResponse.sso_enforcement && (
+ <SSOEnforcedLoginButton
+ provider={precheckResponse.sso_enforcement}
+ email={login.email}
+ isLastUsed={lastLoginMethod === precheckResponse.sso_enforcement}
+ />
+ )}
+
+ {/* Show optional SAML SSO button if available */}
+ {precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
+ <SSOEnforcedLoginButton
+ provider="saml"
+ email={login.email}
+ isLastUsed={lastLoginMethod === 'saml'}
+ />
+ )}
+ </Form>
+ )}
+ {!isEmailVerificationSent && preflight?.cloud && (
+ <div className="text-center mt-4">
+ Don't have an account?{' '}
+ <Link to={[signupUrl, { email: login.email }]} data-attr="signup" className="font-bold">
+ Create an account
+ </Link>
+ </div>
+ )}
+ {!isEmailVerificationSent && !precheckResponse.saml_available && !precheckResponse.sso_enforcement && (
+ <SocialLoginButtons
+ caption="Or log in with"
+ topDivider
+ lastUsedProvider={lastLoginMethod}
+ showPasskey
+ />
+ )}
+ {allowDevLogin && (
+ <div className="deprecated-space-y-2 border-t border-dashed pt-4 mt-4">
+ <div className="flex items-center justify-between">
+ <h4 className="m-0">Dev login</h4>
+ </div>
+ <p className="text-muted text-sm m-0">
+ Click a user to log in without a password. This list is only exposed in development mode.
+ </p>
+ {!devUsersLoading && devLoginTimeSavedLabel && (
+ <p className="text-muted text-sm m-0">{devLoginTimeSavedLabel}</p>
+ )}
+ {devUsersLoading && <Skeleton className="w-full h-10" />}
+ <div className="deprecated-space-y-1">
+ {devUsers.map((u) => (
+ <LemonButton
+ key={u.email}
+ type="secondary"
+ fullWidth
+ data-attr={`dev-login-${u.email}`}
+ onClick={() => devLogin(u.email)}
+ >
+ <span className="flex items-center gap-2 w-full">
+ <span className="flex-1 text-left truncate">{u.email}</span>
+ {u.label && (
+ <LemonTag type="success" size="small">
+ {u.label}
+ </LemonTag>
+ )}
+ {u.is_staff && !u.label && (
+ <LemonTag type="default" size="small">
+ Staff
+ </LemonTag>
+ )}
+ </span>
+ </LemonButton>
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ </AuthShell>
+ )
+}
diff --git a/frontend/src/scenes/authentication/login/variants/redesign-2026-06-02/LoginV2.tsx b/frontend/src/scenes/authentication/login/variants/redesign-2026-06-02/LoginV2.tsx
new file mode 100644
index 000000000000..212a0f65a8fa
--- /dev/null
+++ b/frontend/src/scenes/authentication/login/variants/redesign-2026-06-02/LoginV2.tsx
@@ -0,0 +1,13 @@
+import { BridgePage } from 'lib/components/BridgePage/BridgePage'
+
+// TODO: build the redesign-2026-06-02 login; renders under the `auth-flow-variant` flag.
+export function LoginV2(): JSX.Element {
+ return (
+ <BridgePage view="login" hedgehog message="Welcome back">
+ <div className="deprecated-space-y-4">
+ <h2>Log in</h2>
+ <p className="text-secondary">Redesigned sign-in — coming soon.</p>
+ </div>
+ </BridgePage>
+ )
+}
diff --git a/frontend/src/scenes/authentication/signup/SignupContainer.tsx b/frontend/src/scenes/authentication/signup/SignupContainer.tsx
index b674ea370f5e..23e036a837db 100644
--- a/frontend/src/scenes/authentication/signup/SignupContainer.tsx
+++ b/frontend/src/scenes/authentication/signup/SignupContainer.tsx
@@ -1,121 +1,17 @@
import { useValues } from 'kea'
-import { router } from 'kea-router'
-import { IconCheckCircle } from '@posthog/icons'
-
-import { CLOUD_HOSTNAMES, FEATURE_FLAGS } from 'lib/constants'
-import { Link } from 'lib/lemon-ui/Link'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { AuthShell } from 'scenes/authentication/shared/AuthShell'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { SceneExport } from 'scenes/sceneTypes'
-import { userLogic } from 'scenes/userLogic'
-
-import { Region } from '~/types'
-import { SignupForm } from './signupForm/SignupForm'
+import { authFlowVariantRegistry } from '../authFlowVariantRegistry'
+import { resolveAuthFlowVariant } from '../authFlowVariants'
export const scene: SceneExport = {
component: SignupContainer,
}
export function SignupContainer(): JSX.Element | null {
- const { preflight } = useValues(preflightLogic)
- const { user } = useValues(userLogic)
const { featureFlags } = useValues(featureFlagLogic)
-
- const isAATestVariant = featureFlags[FEATURE_FLAGS.SIGNUP_AA_TEST] === 'test'
-
- const footerHighlights = {
- cloud: ['Hosted & managed by PostHog', 'Pay per event, cancel anytime', 'Fast and reliable support'],
- selfHosted: ['Fully featured product, unlimited events', 'Data in your own infrastructure', 'Community forum'],
- }
-
- return !user ? (
- <AuthShell
- view="signup"
- sideLogo
- leftContainerContent={<SignupLeftContainer />}
- footer={
- <div className="sm:flex sm:justify-center w-full gap-[10%]">
- {footerHighlights[preflight?.cloud ? 'cloud' : 'selfHosted'].map((val, idx) => (
- <p key={idx} className="text-center mb-2">
- {val}
- </p>
- ))}
- </div>
- }
- >
- {isAATestVariant && <div data-attr="signup-aa-test-variant" className="hidden" />}
- <SignupForm />
- </AuthShell>
- ) : null
-}
-
-const productBenefits = [
- {
- benefit: 'Free usage every month - even on paid plans',
- description: '1M free events, 5K free session recordings, and more. Every month. Forever.',
- },
- {
- benefit: 'Start collecting data immediately',
- description: 'Integrate with developer-friendly APIs or a low-code web snippet.',
- },
- {
- benefit: 'Join industry leaders that run on PostHog',
- description: 'Airbus, Hasura, Y Combinator, Staples, and thousands more trust PostHog as their Product OS.',
- },
-]
-
-export function SignupLeftContainer(): JSX.Element {
- const { preflight } = useValues(preflightLogic)
-
- const getRegionUrl = (region: Region): string => {
- const { pathname, search, hash } = router.values.currentLocation
- return `https://${CLOUD_HOSTNAMES[region]}${pathname}${search}${hash}`
- }
-
- return (
- <>
- <div className="mb-16 max-w-100">
- {productBenefits.map((benefit, i) => (
- <div className="flex flex-row gap-3 mb-4" key={i}>
- <div>
- <IconCheckCircle className="mt-0.5 w-5 h-5 text-link" />
- </div>
- <div>
- <h3 className="mb-1 font-bold leading-6">{benefit.benefit}</h3>
- <p className="m-0 text-sm">{benefit.description}</p>
- </div>
- </div>
- ))}
- </div>
- <div className="BridgePage__cta border rounded p-4 mt-8 text-center">
- Did you know?
- {preflight?.cloud ? (
- <span>
- {' '}
- You can use our{' '}
- <Link to={getRegionUrl(preflight?.region === Region.EU ? Region.US : Region.EU)}>
- <strong>PostHog Cloud {preflight?.region === Region.EU ? 'US' : 'EU'}</strong>
- </Link>
- {preflight?.region === Region.EU ? ', too' : ' for a GDPR-ready deployment'}.
- </span>
- ) : (
- <span>
- {' '}
- You can use our{' '}
- <Link to={getRegionUrl(Region.EU)}>
- <strong>{Region.EU} cloud</strong>
- </Link>{' '}
- or{' '}
- <Link to={getRegionUrl(Region.US)}>
- <strong>{Region.US} cloud</strong>
- </Link>{' '}
- and we'll take care of the hosting for you.
- </span>
- )}
- </div>
- </>
- )
+ const { Signup: VariantSignup } = authFlowVariantRegistry[resolveAuthFlowVariant(featureFlags)]
+ return <VariantSignup />
}
diff --git a/frontend/src/scenes/authentication/signup/variants/legacy/LegacySignup.tsx b/frontend/src/scenes/authentication/signup/variants/legacy/LegacySignup.tsx
new file mode 100644
index 000000000000..3b3a253d790e
--- /dev/null
+++ b/frontend/src/scenes/authentication/signup/variants/legacy/LegacySignup.tsx
@@ -0,0 +1,116 @@
+import { useValues } from 'kea'
+import { router } from 'kea-router'
+
+import { IconCheckCircle } from '@posthog/icons'
+
+import { CLOUD_HOSTNAMES, FEATURE_FLAGS } from 'lib/constants'
+import { Link } from 'lib/lemon-ui/Link'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { AuthShell } from 'scenes/authentication/shared/AuthShell'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { userLogic } from 'scenes/userLogic'
+
+import { Region } from '~/types'
+
+import { SignupForm } from '../../signupForm/SignupForm'
+
+export function LegacySignup(): JSX.Element | null {
+ const { preflight } = useValues(preflightLogic)
+ const { user } = useValues(userLogic)
+ const { featureFlags } = useValues(featureFlagLogic)
+
+ const isAATestVariant = featureFlags[FEATURE_FLAGS.SIGNUP_AA_TEST] === 'test'
+
+ const footerHighlights = {
+ cloud: ['Hosted & managed by PostHog', 'Pay per event, cancel anytime', 'Fast and reliable support'],
+ selfHosted: ['Fully featured product, unlimited events', 'Data in your own infrastructure', 'Community forum'],
+ }
+
+ return !user ? (
+ <AuthShell
+ view="signup"
+ sideLogo
+ leftContainerContent={<SignupLeftContainer />}
+ footer={
+ <div className="sm:flex sm:justify-center w-full gap-[10%]">
+ {footerHighlights[preflight?.cloud ? 'cloud' : 'selfHosted'].map((val, idx) => (
+ <p key={idx} className="text-center mb-2">
+ {val}
+ </p>
+ ))}
+ </div>
+ }
+ >
+ {isAATestVariant && <div data-attr="signup-aa-test-variant" className="hidden" />}
+ <SignupForm />
+ </AuthShell>
+ ) : null
+}
+
+const productBenefits = [
+ {
+ benefit: 'Free usage every month - even on paid plans',
+ description: '1M free events, 5K free session recordings, and more. Every month. Forever.',
+ },
+ {
+ benefit: 'Start collecting data immediately',
+ description: 'Integrate with developer-friendly APIs or a low-code web snippet.',
+ },
+ {
+ benefit: 'Join industry leaders that run on PostHog',
+ description: 'Airbus, Hasura, Y Combinator, Staples, and thousands more trust PostHog as their Product OS.',
+ },
+]
+
+export function SignupLeftContainer(): JSX.Element {
+ const { preflight } = useValues(preflightLogic)
+
+ const getRegionUrl = (region: Region): string => {
+ const { pathname, search, hash } = router.values.currentLocation
+ return `https://${CLOUD_HOSTNAMES[region]}${pathname}${search}${hash}`
+ }
+
+ return (
+ <>
+ <div className="mb-16 max-w-100">
+ {productBenefits.map((benefit, i) => (
+ <div className="flex flex-row gap-3 mb-4" key={i}>
+ <div>
+ <IconCheckCircle className="mt-0.5 w-5 h-5 text-link" />
+ </div>
+ <div>
+ <h3 className="mb-1 font-bold leading-6">{benefit.benefit}</h3>
+ <p className="m-0 text-sm">{benefit.description}</p>
+ </div>
+ </div>
+ ))}
+ </div>
+ <div className="BridgePage__cta border rounded p-4 mt-8 text-center">
+ Did you know?
+ {preflight?.cloud ? (
+ <span>
+ {' '}
+ You can use our{' '}
+ <Link to={getRegionUrl(preflight?.region === Region.EU ? Region.US : Region.EU)}>
+ <strong>PostHog Cloud {preflight?.region === Region.EU ? 'US' : 'EU'}</strong>
+ </Link>
+ {preflight?.region === Region.EU ? ', too' : ' for a GDPR-ready deployment'}.
+ </span>
+ ) : (
+ <span>
+ {' '}
+ You can use our{' '}
+ <Link to={getRegionUrl(Region.EU)}>
+ <strong>{Region.EU} cloud</strong>
+ </Link>{' '}
+ or{' '}
+ <Link to={getRegionUrl(Region.US)}>
+ <strong>{Region.US} cloud</strong>
+ </Link>{' '}
+ and we'll take care of the hosting for you.
+ </span>
+ )}
+ </div>
+ </>
+ )
+}
diff --git a/frontend/src/scenes/authentication/signup/variants/redesign-2026-06-02/SignupV2.tsx b/frontend/src/scenes/authentication/signup/variants/redesign-2026-06-02/SignupV2.tsx
new file mode 100644
index 000000000000..e9210b99f40d
--- /dev/null
+++ b/frontend/src/scenes/authentication/signup/variants/redesign-2026-06-02/SignupV2.tsx
@@ -0,0 +1,18 @@
+import { useValues } from 'kea'
+
+import { BridgePage } from 'lib/components/BridgePage/BridgePage'
+import { userLogic } from 'scenes/userLogic'
+
+// TODO: build the redesign-2026-06-02 signup; renders under the `auth-flow-variant` flag.
+export function SignupV2(): JSX.Element | null {
+ const { user } = useValues(userLogic)
+
+ return !user ? (
+ <BridgePage view="signup" sideLogo>
+ <div className="deprecated-space-y-4">
+ <h2>Create your account</h2>
+ <p className="text-secondary">Redesigned signup — coming soon.</p>
+ </div>
+ </BridgePage>
+ ) : null
+}