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.

fix(signup): let users retry after a failed signup step (#83344)

Patricio7310a065e56c
diff --git a/.test_quarantine.json b/.test_quarantine.json
index 57790a53aa0d..4c2b065e9b6a 100644
--- a/.test_quarantine.json
+++ b/.test_quarantine.json
@@ -31,15 +31,6 @@
"expires": "2026-08-20",
"mode": "run"
},
- {
- "id": "playwright/e2e/signup.spec.ts::Signup Can submit the signup form multiple times if there is a generic email set",
- "runner": "playwright",
- "reason": "Reproduced identically on two independent fresh CI runs of this PR; unrelated to data warehouse sources and not touched by this diff",
- "owner": "@team-growth",
- "added": "2026-08-13",
- "expires": "2026-08-20",
- "mode": "run"
- },
{
"id": "products/ai_observability/frontend/e2e/multimodal-trace.spec.ts",
"runner": "playwright",
diff --git a/frontend/src/scenes/authentication/signup/signupForm/SignupForm.test.tsx b/frontend/src/scenes/authentication/signup/Signup.test.tsx
similarity index 74%
rename from frontend/src/scenes/authentication/signup/signupForm/SignupForm.test.tsx
rename to frontend/src/scenes/authentication/signup/Signup.test.tsx
index c3b66b32bdc0..9dd2c8c9eb2b 100644
--- a/frontend/src/scenes/authentication/signup/signupForm/SignupForm.test.tsx
+++ b/frontend/src/scenes/authentication/signup/Signup.test.tsx
@@ -8,9 +8,9 @@ import { router } from 'kea-router'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { SignupForm } from './SignupForm'
+import { Signup } from './Signup'
-describe('SignupForm', () => {
+describe('Signup', () => {
let signupRequestBody: Record<string, any> | null
beforeEach(() => {
@@ -37,7 +37,7 @@ describe('SignupForm', () => {
router.actions.push('/signup')
render(
<Provider>
- <SignupForm />
+ <Signup />
</Provider>
)
})
@@ -81,43 +81,32 @@ describe('SignupForm', () => {
expect(screen.getByTestId('signup-email')).toBeInTheDocument()
})
- it('a too-short password shows the min-length error; a valid one advances to onboarding', async () => {
+ it('a too-short password blocks the auth panel; a valid one advances to onboarding', async () => {
await submitEmail('[email protected]')
await submitPassword('123')
- expect(await screen.findByText('Must be at least 8 characters long')).toBeVisible()
+ expect(await screen.findByTestId('signup-auth-continue')).toHaveAttribute('aria-disabled', 'true')
expect(screen.queryByTestId('signup-name')).not.toBeInTheDocument()
await userEvent.clear(screen.getByTestId('password'))
await submitPassword('Str0ng-Test-Pass!')
expect(await screen.findByTestId('signup-name')).toBeInTheDocument()
- expect(screen.queryByText('Must be at least 8 characters long')).not.toBeInTheDocument()
})
- it('a padded full name reaches the signup payload trimmed and split into first and last name', async () => {
+ // The panels are the only place the three forms get wired to the logic, so this walkthrough
+ // guards that wiring. The payload shaping itself is covered in signupLogic.test.ts.
+ it('walks all three panels and posts what was typed into them', async () => {
await submitEmail('[email protected]')
await submitPassword('Str0ng-Test-Pass!')
- // A leading space used to slip through client validation and produce first_name: ""
- await fillOnboardingAndSubmit({ name: ' Alice Bob', organizationName: 'Hogflix SpinOff' })
+ await fillOnboardingAndSubmit({ name: 'Alice Bob', organizationName: 'Hogflix SpinOff' })
await waitFor(() => {
expect(signupRequestBody).not.toBeNull()
})
+ expect(signupRequestBody?.email).toBe('[email protected]')
+ expect(signupRequestBody?.password).toBe('Str0ng-Test-Pass!')
expect(signupRequestBody?.first_name).toBe('Alice')
expect(signupRequestBody?.last_name).toBe('Bob')
expect(signupRequestBody?.organization_name).toBe('Hogflix SpinOff')
})
-
- it('a single-word name sends first_name only and omits the blank organization name', async () => {
- await submitEmail('[email protected]')
- await submitPassword('Str0ng-Test-Pass!')
- await fillOnboardingAndSubmit({ name: 'Alice' })
-
- await waitFor(() => {
- expect(signupRequestBody).not.toBeNull()
- })
- expect(signupRequestBody?.first_name).toBe('Alice')
- expect(signupRequestBody).not.toHaveProperty('last_name')
- expect(signupRequestBody).not.toHaveProperty('organization_name')
- })
})
diff --git a/frontend/src/scenes/authentication/signup/signupForm/JoinExistingOrgLink.tsx b/frontend/src/scenes/authentication/signup/signupForm/JoinExistingOrgLink.tsx
deleted file mode 100644
index d08888e8e363..000000000000
--- a/frontend/src/scenes/authentication/signup/signupForm/JoinExistingOrgLink.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { IconLetter } from '@posthog/icons'
-
-import { LemonDialog } from 'lib/lemon-ui/LemonDialog'
-import { Link } from 'lib/lemon-ui/Link'
-
-function openJoinExistingOrgDialog(): void {
- LemonDialog.open({
- width: 480,
- content: (
- <div className="flex flex-col items-center text-center px-2 pt-2 pb-4">
- <div className="flex items-center justify-center w-14 h-14 rounded-full bg-accent-highlight-secondary mb-4">
- <IconLetter className="text-2xl text-accent" />
- </div>
- <h2 className="text-xl font-bold mb-2">You'll need your invite link to join</h2>
- <p className="text-secondary mb-2">
- When a teammate invites you to a PostHog organization, we email you a personal invite link. You can
- only join the existing organization by opening that email and clicking the link.
- </p>
- <p className="text-secondary text-sm mb-0">
- Didn't get an email? Check your spam folder, or ask the teammate who invited you to resend it from
- the organization's members settings.
- </p>
- </div>
- ),
- primaryButton: {
- children: 'Got it',
- type: 'primary',
- },
- })
-}
-
-export function JoinExistingOrgLink(): JSX.Element {
- return (
- <div className="text-center mt-3 text-xs">
- <Link onClick={openJoinExistingOrgDialog} data-attr="signup-join-existing-org" className="text-secondary">
- Trying to join an existing organization?
- </Link>
- </div>
- )
-}
diff --git a/frontend/src/scenes/authentication/signup/signupForm/SignupForm.tsx b/frontend/src/scenes/authentication/signup/signupForm/SignupForm.tsx
deleted file mode 100644
index a3ec54f342f2..000000000000
--- a/frontend/src/scenes/authentication/signup/signupForm/SignupForm.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { useEffect, useState } from 'react'
-
-import { IconArrowLeft } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
-
-import { supportLogic } from 'lib/components/Support/supportLogic'
-import { LemonBanner } from 'lib/lemon-ui/LemonBanner'
-import { Link } from 'lib/lemon-ui/Link'
-import { SpinnerOverlay } from 'lib/lemon-ui/Spinner/Spinner'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
-import { SceneExport } from 'scenes/sceneTypes'
-
-import { userLogic } from '../../../userLogic'
-import { SignupPanelAuth } from './panels/SignupPanelAuth'
-import { SignupPanelEmail } from './panels/SignupPanelEmail'
-import { SignupPanelOnboarding } from './panels/SignupPanelOnboarding'
-import { signupLogic } from './signupLogic'
-
-export const scene: SceneExport = {
- component: SignupForm,
- logic: signupLogic,
-}
-
-export function SignupForm(): JSX.Element | null {
- const { user } = useValues(userLogic)
- const {
- isSignupPanelOnboardingSubmitting,
- signupPanelOnboardingManualErrors,
- signupPanelEmail,
- panel,
- panelTitle,
- } = useValues(signupLogic)
- const { setPanel } = useActions(signupLogic)
- const { preflight } = useValues(preflightLogic)
- const { openSupportForm } = useActions(supportLogic)
- const [showSpinner, setShowSpinner] = useState(true)
-
- const supportLink = preflight?.cloud ? (
- <>
- {' '}
- <Link
- data-attr="login-error-contact-support"
- onClick={(e) => {
- e.preventDefault()
- openSupportForm({ kind: 'support', email: signupPanelEmail.email })
- }}
- >
- Contact us
- </Link>{' '}
- to resolve this.
- </>
- ) : null
-
- useEffect(() => {
- setShowSpinner(true)
- const t = setTimeout(() => {
- setShowSpinner(false)
- }, 500)
- return () => clearTimeout(t)
- }, [panel])
-
- return !user ? (
- <div className="deprecated-space-y-2">
- {panelTitle ? <h2>{panelTitle}</h2> : null}
- {!isSignupPanelOnboardingSubmitting && signupPanelOnboardingManualErrors?.generic && (
- <LemonBanner type="error">
- {signupPanelOnboardingManualErrors.generic?.detail ||
- 'Could not complete your signup. Please try again.'}
- {supportLink}
- </LemonBanner>
- )}
- {panel === 0 ? (
- <SignupPanelEmail />
- ) : panel === 1 ? (
- <>
- <SignupPanelAuth />
- <div className="flex justify-center">
- <LemonButton
- icon={<IconArrowLeft />}
- onClick={() => setPanel(0)}
- size="small"
- center
- data-attr="signup-go-back"
- >
- or go back
- </LemonButton>
- </div>
- </>
- ) : (
- <>
- <SignupPanelOnboarding />
- <div className="flex justify-center">
- <LemonButton
- icon={<IconArrowLeft />}
- onClick={() => setPanel(panel - 1)}
- size="small"
- center
- data-attr="signup-go-back"
- >
- or go back
- </LemonButton>
- </div>
- </>
- )}
- {showSpinner ? <SpinnerOverlay sceneLevel /> : null}
- </div>
- ) : null
-}
diff --git a/frontend/src/scenes/authentication/signup/signupForm/panels/PendingInviteBanner.tsx b/frontend/src/scenes/authentication/signup/signupForm/panels/PendingInviteBanner.tsx
deleted file mode 100644
index 776fe6a5ea4d..000000000000
--- a/frontend/src/scenes/authentication/signup/signupForm/panels/PendingInviteBanner.tsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import { useActions, useValues } from 'kea'
-
-import { LemonBanner, LemonButton } from '@posthog/lemon-ui'
-
-import { PendingInvite, signupLogic } from '../signupLogic'
-
-export function PendingInviteBanner({ invite, email }: { invite: PendingInvite; email: string }): JSX.Element {
- const { isPendingInviteResending, pendingInviteResent } = useValues(signupLogic)
- const { resendPendingInvite, dismissPendingInvite } = useActions(signupLogic)
-
- return (
- <div className="deprecated-space-y-4 Signup__panel__pending-invite">
- <h2 className="m-0">You've already been invited to PostHog</h2>
- <p className="text-secondary mb-0">
- <b>{invite.organization_name}</b> sent you an invite to join them on PostHog. Look for it in your inbox,
- or have us resend it.
- </p>
- {pendingInviteResent ? (
- <LemonBanner type="success">
- Sent. Check your inbox for the invite link from {invite.organization_name}.
- </LemonBanner>
- ) : (
- <>
- <LemonButton
- type="primary"
- status="alt"
- fullWidth
- center
- size="large"
- onClick={() => resendPendingInvite(email)}
- loading={isPendingInviteResending}
- data-attr="pending-invite-resend"
- >
- Resend invite email
- </LemonButton>
- <LemonButton
- type="secondary"
- fullWidth
- center
- onClick={dismissPendingInvite}
- data-attr="pending-invite-create-own-org"
- >
- I'd like to create my own organization
- </LemonButton>
- </>
- )}
- </div>
- )
-}
diff --git a/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelAuth.tsx b/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelAuth.tsx
deleted file mode 100644
index 0a3ad20e57b6..000000000000
--- a/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelAuth.tsx
+++ /dev/null
@@ -1,103 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { Form } from 'kea-forms'
-
-import { LemonBanner, LemonButton, LemonInput } from '@posthog/lemon-ui'
-
-import PasswordStrength from 'lib/components/PasswordStrength'
-import passkeyLogo from 'lib/components/SocialLoginButton/passkey.svg'
-import { IconKey } from 'lib/lemon-ui/icons'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-
-import { signupLogic } from '../signupLogic'
-
-export function SignupPanelAuth(): JSX.Element | null {
- const { registerPasskey } = useActions(signupLogic)
- const {
- isSignupPanelAuthSubmitting,
- validatedPassword,
- signupPanelEmail,
- passkeyRegistered,
- isPasskeyRegistering,
- passkeyError,
- } = useValues(signupLogic)
-
- return (
- <div className="deprecated-space-y-4 Signup__panel__auth">
- <div className="text-center mb-4">
- <p className="text-secondary mb-1">Signing up as</p>
- <p className="font-semibold text-lg">{signupPanelEmail.email}</p>
- </div>
-
- {passkeyError && (
- <LemonBanner type="error" className="mb-4">
- {passkeyError}
- </LemonBanner>
- )}
-
- {passkeyRegistered ? (
- <div className="border border-success-lighter rounded-lg p-4 bg-success-highlight text-center">
- <img src={passkeyLogo} alt="Passkey" className="w-8 h-8 mx-auto mb-2" />
- <p className="font-semibold text-success mb-1">Passkey registered successfully!</p>
- <p className="text-secondary text-sm">You can use this passkey to sign in to 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="signup-passkey"
- >
- Sign up with passkey
- </LemonButton>
- )}
-
- <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>
-
- <Form logic={signupLogic} formKey="signupPanelAuth" className="deprecated-space-y-4" enableFormOnSubmit>
- <LemonField
- name="password"
- label={
- <div className="flex flex-1 items-center justify-between">
- <span className="flex items-center gap-1">
- <IconKey className="text-muted" />
- Password
- </span>
- <PasswordStrength validatedPassword={validatedPassword} />
- </div>
- }
- >
- <LemonInput
- type="password"
- autoComplete="new-password"
- className="ph-ignore-input"
- data-attr="password"
- placeholder="••••••••••"
- disabled={isSignupPanelAuthSubmitting || passkeyRegistered}
- />
- </LemonField>
- <LemonButton
- fullWidth
- type="primary"
- status="alt"
- center
- htmlType="submit"
- data-attr="signup-auth-continue"
- loading={isSignupPanelAuthSubmitting}
- disabled={isSignupPanelAuthSubmitting}
- size="large"
- >
- Continue
- </LemonButton>
- </Form>
- </div>
- )
-}
diff --git a/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelEmail.tsx b/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelEmail.tsx
deleted file mode 100644
index b1137b31f15f..000000000000
--- a/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelEmail.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import { useValues } from 'kea'
-import { Form } from 'kea-forms'
-import { useEffect, useRef } from 'react'
-
-import { LemonBanner, LemonButton, LemonInput } from '@posthog/lemon-ui'
-
-import { SocialLoginButtons } from 'lib/components/SocialLoginButton/SocialLoginButton'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-import { Link } from 'lib/lemon-ui/Link'
-import RegionSelect from 'scenes/authentication/shared/RegionSelect'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
-
-import { JoinExistingOrgLink } from '../JoinExistingOrgLink'
-import { signupLogic } from '../signupLogic'
-import { PendingInviteBanner } from './PendingInviteBanner'
-
-export function SignupPanelEmail(): JSX.Element | null {
- const { preflight, socialAuthAvailable } = useValues(preflightLogic)
- const {
- isSignupPanelEmailSubmitting,
- loginUrl,
- emailCaseNotice,
- passkeyError,
- error,
- pendingInvite,
- signupPanelEmail,
- } = useValues(signupLogic)
- const emailInputRef = useRef<HTMLInputElement | null>(null)
-
- useEffect(() => {
- emailInputRef?.current?.focus()
- }, [])
-
- if (pendingInvite) {
- return <PendingInviteBanner invite={pendingInvite} email={signupPanelEmail.email} />
- }
-
- return (
- <div className="deprecated-space-y-4 Signup__panel__email">
- <RegionSelect />
- {passkeyError && (
- <LemonBanner type="error" className="mb-4">
- {passkeyError}
- </LemonBanner>
- )}
- {!preflight?.demo && socialAuthAvailable && (
- <>
- <SocialLoginButtons caption="Sign up with" bottomDivider className="mt-6" />
- <p className="text-secondary text-center mb-0">Or use email</p>
- </>
- )}
- <Form logic={signupLogic} formKey="signupPanelEmail" className="deprecated-space-y-4" enableFormOnSubmit>
- <LemonField
- name="email"
- label="Email"
- help={emailCaseNotice && <span className="text-warning">{emailCaseNotice}</span>}
- >
- <LemonInput
- className="ph-ignore-input"
- autoFocus
- data-attr="signup-email"
- placeholder="[email protected]"
- type="email"
- inputRef={emailInputRef}
- />
- </LemonField>
- {error && <LemonBanner type="error">{error}</LemonBanner>}
- <LemonButton
- fullWidth
- type="primary"
- status="alt"
- center
- htmlType="submit"
- data-attr="signup-start"
- loading={isSignupPanelEmailSubmitting}
- size="large"
- >
- Continue
- </LemonButton>
- </Form>
- {!preflight?.demo && (preflight?.cloud || preflight?.initiated) && (
- <div className="text-center mt-4">
- Already have an account?{' '}
- <Link to={loginUrl} data-attr="signup-login-link" className="font-bold">
- Log in
- </Link>
- </div>
- )}
- {!preflight?.demo && <JoinExistingOrgLink />}
- </div>
- )
-}
diff --git a/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelOnboarding.tsx b/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelOnboarding.tsx
deleted file mode 100644
index c3dee0ec58cf..000000000000
--- a/frontend/src/scenes/authentication/signup/signupForm/panels/SignupPanelOnboarding.tsx
+++ /dev/null
@@ -1,94 +0,0 @@
-import { useActions, useValues } from 'kea'
-import { Form } from 'kea-forms'
-
-import { LemonButton, LemonInput, Link } from '@posthog/lemon-ui'
-
-import SignupReferralSource from 'lib/components/SignupReferralSource'
-import SignupRoleSelect from 'lib/components/SignupRoleSelect'
-import { LemonField } from 'lib/lemon-ui/LemonField'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
-
-import { signupLogic } from '../signupLogic'
-import { TurnstileChallenge } from '../TurnstileChallenge'
-
-const UTM_TAGS = 'utm_campaign=in-product&utm_tag=signup-header'
-
-export function SignupPanelOnboarding(): JSX.Element | null {
- const { preflight } = useValues(preflightLogic)
- const { setSignupPanelOnboardingManualErrors } = useActions(signupLogic)
- const { isSignupPanelOnboardingSubmitting, challengeRequired, turnstileSiteKey, turnstileToken, signupPanelEmail } =
- useValues(signupLogic)
- const { setTurnstileToken } = useActions(signupLogic)
-
- return (
- <div className="deprecated-space-y-4 Signup__panel__onboarding">
- <Form
- logic={signupLogic}
- formKey="signupPanelOnboarding"
- className="deprecated-space-y-4"
- enableFormOnSubmit
- >
- <LemonField name="name" label="Your name">
- <LemonInput
- className="ph-ignore-input"
- autoFocus
- data-attr="signup-name"
- placeholder="Jane Doe"
- disabled={isSignupPanelOnboardingSubmitting}
- />
- </LemonField>
- <LemonField name="organization_name" label="Organization name">
- <LemonInput
- className="ph-ignore-input"
- data-attr="signup-organization-name"
- placeholder="Hogflix Movies"
- disabled={isSignupPanelOnboardingSubmitting}
- />
- </LemonField>
- <SignupRoleSelect />
- <SignupReferralSource disabled={isSignupPanelOnboardingSubmitting} />
- <div className="divider" />
-
- {challengeRequired && turnstileSiteKey ? (
- <TurnstileChallenge
- siteKey={turnstileSiteKey}
- onSuccess={setTurnstileToken}
- tokenReceived={!!turnstileToken}
- email={signupPanelEmail.email}
- />
- ) : (
- <LemonButton
- fullWidth
- type="primary"
- center
- htmlType="submit"
- data-attr="signup-submit"
- onClick={() => setSignupPanelOnboardingManualErrors({})}
- loading={isSignupPanelOnboardingSubmitting}
- disabled={isSignupPanelOnboardingSubmitting}
- status="alt"
- size="large"
- >
- {!preflight?.demo
- ? 'Create account'
- : !isSignupPanelOnboardingSubmitting
- ? 'Enter the demo environment'
- : 'Preparing demo data…'}
- </LemonButton>
- )}
- </Form>
-
- <div className="text-center text-secondary">
- By {!preflight?.demo ? 'creating an account' : 'entering the demo environment'}, you agree to our{' '}
- <Link to={`https://posthog.com/terms?${UTM_TAGS}`} target="_blank">
- Terms of Service
- </Link>{' '}
- and{' '}
- <Link to={`https://posthog.com/privacy?${UTM_TAGS}`} target="_blank">
- Privacy Policy
- </Link>
- .
- </div>
- </div>
- )
-}
diff --git a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts
index d7796e1e4553..cdcebf5b6783 100644
--- a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts
+++ b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.test.ts
@@ -142,6 +142,91 @@ describe('signupLogic — pending invite banner', () => {
})
})
+describe('signupLogic — retrying a panel after a failed submit', () => {
+ let logic: ReturnType<typeof signupLogic.build>
+ let signupRequestCount: number
+
+ const advanceToOnboardingPanel = async (): Promise<void> => {
+ logic.actions.setSignupPanelEmailValue('email', '[email protected]')
+ logic.actions.submitSignupPanelEmail()
+ await expectLogic(logic).toFinishAllListeners()
+ logic.actions.setSignupPanelAuthValue('password', 'Str0ng-Test-Pass!')
+ logic.actions.submitSignupPanelAuth()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.panel).toBe(2)
+ }
+
+ beforeEach(() => {
+ signupRequestCount = 0
+ useMocks({
+ post: {
+ '/api/signup/precheck': async (info) => {
+ const { email } = (await info.request.clone().json()) as { email: string }
+ return email === '[email protected]'
+ ? [
+ 409,
+ {
+ type: 'validation_error',
+ code: 'account_exists',
+ detail: 'There is already an account with this email address.',
+ },
+ ]
+ : [200, { email_exists: false, pending_invite: null }]
+ },
+ '/api/signup/': () => {
+ signupRequestCount++
+ return [400, { type: 'validation_error', code: 'error', detail: 'Mocked failure', attr: null }]
+ },
+ },
+ })
+ initKeaTests()
+ router.actions.push('/signup')
+ logic = signupLogic()
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ })
+
+ it('advances when a different email is submitted after an account-exists error', async () => {
+ logic.actions.setSignupPanelEmailValue('email', '[email protected]')
+ logic.actions.submitSignupPanelEmail()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.panel).toBe(0)
+ expect(logic.values.signupPanelEmailManualErrors.email).toBe(
+ 'There is already an account with this email address.'
+ )
+
+ logic.actions.setSignupPanelEmailValue('email', '[email protected]')
+ logic.actions.submitSignupPanelEmail()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.panel).toBe(1)
+ expect(logic.values.signupPanelEmailManualErrors.email).toBeUndefined()
+ })
+
+ it('reissues the signup request when onboarding is submitted again after a generic error', async () => {
+ await advanceToOnboardingPanel()
+ logic.actions.setSignupPanelOnboardingValues({
+ name: 'John Smith',
+ organization_name: 'Hogflix',
+ role_at_organization: 'engineer',
+ referral_source: '',
+ referral_source_ai_prompt: '',
+ })
+ logic.actions.submitSignupPanelOnboarding()
+ await expectLogic(logic).toFinishAllListeners()
+ expect(signupRequestCount).toBe(1)
+ expect(logic.values.signupPanelOnboardingManualErrors.generic).not.toBeUndefined()
+
+ logic.actions.submitSignupPanelOnboarding()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(signupRequestCount).toBe(2)
+ })
+})
+
describe('signupLogic — name handling', () => {
let logic: ReturnType<typeof signupLogic.build>
let signupRequestBody: Record<string, any> | null
diff --git a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts
index 40b14626fc47..6cfe713a9434 100644
--- a/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts
+++ b/frontend/src/scenes/authentication/signup/signupForm/signupLogic.ts
@@ -68,7 +68,6 @@ export interface signupLogicValues {
challengeRequired: boolean
emailCaseNotice: string | undefined
emailWasNormalized: boolean
- error: string | null
isPasskeyRegistering: boolean
isPendingInviteResending: boolean
isSignupPanelAuthSubmitting: boolean
@@ -79,7 +78,6 @@ export interface signupLogicValues {
isSignupPanelOnboardingValid: boolean
loginUrl: string
panel: number
- panelTitle: string
passkeyError: string | null
passkeyRegistered: boolean
pendingInvite: PendingInvite | null
@@ -154,9 +152,6 @@ export interface signupLogicActions {
setEmailNormalized: (wasNormalized: boolean) => {
wasNormalized: boolean
}
- setError: (error: string | null) => {
- error: string | null
- }
setPanel: (panel: number) => {
panel: number
}
@@ -288,7 +283,6 @@ export interface signupLogicMeta {
validatedPassword: (signupPanelAuth: SignupPanelAuthForm) => ValidatedPasswordResult
emailCaseNotice: (emailWasNormalized: boolean) => string | undefined
loginUrl: (searchParams: Record<string, any>) => string
- panelTitle: (panel: number, preflight: PreflightStatus | null, pendingInvite: PendingInvite | null) => string
}
}
@@ -308,7 +302,6 @@ export const signupLogic = kea<signupLogicType>([
setPasskeyRegistered: (registered: boolean) => ({ registered }),
setPasskeyRegistering: (registering: boolean) => ({ registering }),
setPasskeyError: (error: string | null) => ({ error }),
- setError: (error: string | null) => ({ error }),
// Turnstile challenge actions
setChallengeRequired: (required: boolean) => ({ required }),
setChallengeNonce: (nonce: string | null) => ({ nonce }),
@@ -354,12 +347,6 @@ export const signupLogic = kea<signupLogicType>([
registerPasskey: () => null,
},
],
- error: [
- null as string | null,
- {
- setError: (_, { error }) => error,
- },
- ],
challengeRequired: [
false,
{
@@ -423,11 +410,16 @@ export const signupLogic = kea<signupLogicType>([
? 'Please use a valid email address'
: undefined,
}),
+ // kea-forms counts manual errors as validation errors and refuses to submit while any
+ // are set, and it only clears them when the field is touched or the form is reset. So
+ // the "account already exists" error from a previous attempt would block every later
+ // submit, leaving the user stuck on the email panel with a different email typed in.
+ preSubmit: () => {
+ actions.setSignupPanelEmailManualErrors({})
+ },
submit: async ({ email }, breakpoint) => {
breakpoint()
- actions.setSignupPanelEmailManualErrors({})
actions.setPasskeyError(null)
- actions.setError(null)
let precheckResponse: SignupEmailPrecheckResponse
try {
precheckResponse = await api.create<SignupEmailPrecheckResponse>('api/signup/precheck', {
@@ -439,7 +431,6 @@ export const signupLogic = kea<signupLogicType>([
actions.setSignupPanelEmailManualErrors({
email: errorMessage,
})
- actions.setError(errorMessage)
actions.setPanel(0)
return
}
@@ -497,6 +488,11 @@ export const signupLogic = kea<signupLogicType>([
name: !name?.trim() ? 'Please enter your name' : undefined,
role_at_organization: !role_at_organization ? 'Please select your role in the organization' : undefined,
}),
+ // Same reason as the email panel: without this, the generic or name error left behind by
+ // a failed signup would make every retry of this form a no-op.
+ preSubmit: () => {
+ actions.setSignupPanelOnboardingManualErrors({})
+ },
submit: async (payload, breakpoint) => {
breakpoint()
try {
@@ -609,30 +605,6 @@ export const signupLogic = kea<signupLogicType>([
return nextParam ? `/login?next=${encodeURIComponent(nextParam)}` : '/login'
},
],
- panelTitle: [
- (s) => [s.panel, s.preflight, s.pendingInvite],
- (
- panel: number,
- preflight: null | import('../../../../types').PreflightStatus,
- pendingInvite: PendingInvite | null
- ): string => {
- if (panel === 0 && pendingInvite) {
- return ''
- }
- if (preflight?.demo) {
- return 'Explore PostHog yourself'
- }
-
- switch (panel) {
- case 1:
- return 'Choose how to sign in'
- case 2:
- return 'Tell us a bit about yourself'
- default:
- return 'Get started'
- }
- },
- ],
}),
listeners(({ actions, values }) => ({
dismissPendingInvite: () => {