Skip to content

feat: handle existing customer email during signup (BA-67)#353

Draft
cursor[bot] wants to merge 7 commits intomainfrom
cursor/handle-existing-customer-email-e88f
Draft

feat: handle existing customer email during signup (BA-67)#353
cursor[bot] wants to merge 7 commits intomainfrom
cursor/handle-existing-customer-email-e88f

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented Apr 28, 2026

Summary

This PR adds functionality to detect when a user attempts to sign up with an email that already belongs to an existing Amplitude customer, and offers them options to either log in with the existing account or provide a different email address.

Changes

Core Logic

  • Extended DirectSignupResult type to include optional code field for error identification
  • Updated performDirectSignup to return the error code when the API provides it
  • Modified EmailCaptureScreen to attempt direct signup during email/name capture to detect existing users early

UI/UX

  • Added new "existing user" state to EmailCaptureScreen with three options:
    • Log in with existing account — switches from signup to regular auth flow
    • Use a different email — returns to email entry step
    • Cancel — exits the wizard
  • Added loading state ("Checking account status...") while verifying email
  • Added switchToLogin() method to WizardStore for clean flow transition

Analytics

  • Track 'existing user detected during signup' event with zone and error code
  • Track 'signup switched to login' event when user chooses to log in

Testing

  • Added 3 BDD scenarios covering:
    • Detection of existing customer email
    • Choosing to log in instead
    • Choosing to use a different email
  • All existing unit tests and BDD tests pass (102 scenarios, 455 steps)

Technical Details

The implementation calls performDirectSignup immediately after the user enters their full name. This approach:

  • Provides instant feedback if the email is already registered
  • Avoids duplicate account creation
  • Stores tokens if signup succeeds, preventing redundant API calls in bin.ts
  • Falls back gracefully on network errors or other issues

The error code 'user_already_exists' is expected from the provisioning endpoint when an email is already registered. This is the same pattern used by the Stripe CLI for detecting existing accounts.

Closes

BA-67

Slack Thread

Open in Web Open in Cursor 

- Add ToS acceptance tracking to StoredUser and WizardSession
- Create EmailCaptureScreen for collecting user email
- Create ToSScreen with Stripe CLI-style ToS acceptance
- Add email capture and ToS steps to wizard flow (gated by --signup flag)
- Update direct signup to persist ToS acceptance timestamp
- Add TERMS_OF_SERVICE_URL and PRIVACY_POLICY_URL constants
- Add store methods for email capture and ToS acceptance with back-navigation support
- Update router test mock to include new reset methods
- Fix revert callbacks to return false when screens weren't shown (signup=false)

The --signup flow now requires:
1. Email capture (pre-filled from --signup-email if provided)
2. Explicit ToS acceptance before proceeding to authentication

Agent mode auto-approves both steps when --signup flag is used.
- Add EmailCapture and ToS screens to wizard flow diagram
- Update back-navigation table with new screen Esc behavior
- Add BDD scenarios for signup flow with ToS acceptance
- Document email pre-filling from --signup-email flag
- Document ToS decline behavior (routes to cancel outro)
- Implement 'the wizard launches with {string}' step to handle flags
- Add email capture step definitions (enter email, check screen)
- Add ToS step definitions (accept/decline, screen checks)
- Add email pre-fill validation step
- All 99 BDD scenarios now passing
- Update auth task to wait for tosAccepted when --signup is used
- Add EmailCapture and ToS screens to JourneyStepper Auth step
- Ensures browser only opens after user completes email + ToS flow
- Fixes journey stepper showing incorrect completion states

Fixes issue where browser opened prematurely during signup flow
- Update EmailCaptureScreen to collect both email and full name
- Add two-step flow: email first, then full name
- Add setSignupFullName() store method with analytics
- Fixes 401 auth error by ensuring direct signup has all required fields
- Direct signup now works correctly, avoiding OAuth fallback
- Extend DirectSignupResult to include error code for user detection
- Update EmailCaptureScreen to detect 'user_already_exists' error
- Show options to log in or retry with different email
- Add switchToLogin() method to WizardStore
- Add analytics tracking for existing user scenario
- Add BDD test scenarios for existing customer flow
- Use resolveZone() instead of direct session.region access

Closes BA-67
@github-actions
Copy link
Copy Markdown
Contributor

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci django
  • /wizard-ci fastapi
  • /wizard-ci flask
  • /wizard-ci javascript-node
  • /wizard-ci javascript-web
  • /wizard-ci next-js
  • /wizard-ci python
  • /wizard-ci react-router
  • /wizard-ci vue

Test an individual app:

  • /wizard-ci django/django3-saas
  • /wizard-ci fastapi/fastapi3-ai-saas
  • /wizard-ci flask/flask3-social-media
Show more apps
  • /wizard-ci javascript-node/express-todo
  • /wizard-ci javascript-node/fastify-blog
  • /wizard-ci javascript-node/hono-links
  • /wizard-ci javascript-node/koa-notes
  • /wizard-ci javascript-node/native-http-contacts
  • /wizard-ci javascript-web/saas-dashboard
  • /wizard-ci next-js/15-app-router-saas
  • /wizard-ci next-js/15-app-router-todo
  • /wizard-ci next-js/15-pages-router-saas
  • /wizard-ci next-js/15-pages-router-todo
  • /wizard-ci python/meeting-summarizer
  • /wizard-ci react-router/react-router-v7-project
  • /wizard-ci react-router/rrv7-starter
  • /wizard-ci react-router/saas-template
  • /wizard-ci react-router/shopper
  • /wizard-ci vue/movies

Results will be posted here when complete.

- Add signupTokensObtained flag to session to track early token acquisition
- Update bin.ts to skip duplicate signup attempt when tokens already obtained
- Add markSignupTokensObtained() method to WizardStore
- Clear TextInput after email/name submission using key prop
- Use resolveZone() with readDisk: false for zone resolution in screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant