← Back to Pull requests

Require email verification for every new signup #393

Closed
unknown closed this pull request without merging on Nov 29, 2026 04:07 UTC
View on GitHub
unknown unknown commented on Nov 29, 2026 00:38 UTC
Author

Why


Spam signups. The six-digit code has been optional since it shipped in Aug 2025, because "Skip for now" got past it. Since Oct 3, 2026 (f113759a), a calculator run handed straight from its results page has skipped the code entirely. Nothing on the server checked emailVerified, so a script could post to /auth/register under any address. Each such signup started a 30-day Stripe trial and joined the MailerLite trial group, whose welcome sequence then went to an inbox that never signed up.

What changes


  • The code is required. User.emailVerificationPending is set at registration and cleared by the code. While it's set, authenticate() returns 403 EMAIL_NOT_VERIFIED.

  • - It lets through only the verification endpoints, GET /auth/profile, logout, the calculator-lead attach, and billing.
    - The three code endpoints also accept a lapsed subscription. A paid signup that is canceled before entering its code can still verify, then renew.
    - adminAuth reads the account behind the session's address and refuses it while pending. Before, anyone could register an ADMIN_EMAILS address that had no account yet and use the admin pages at once.
  • Spam signups become inert.

  • - The no-card trial grant and the MailerLite join wait for the code. POST /auth/verify-email claims the code, runs activateVerifiedSignup, and only then clears the flag.
    - A pending account can't start a Checkout. Because the flag clears last, that stays true while the trial grant is still running, so a Checkout can't be finished beside the trial and bill twice. /subscribe sends that refusal to the code page.
    - The nightly mailerlite-sync skips pending accounts.
    - This reverses the registration-time subscribe kept in 746ac0f7, at the owner's request.
  • Calculator signups.

  • - A lead token that only ever reached its own inbox still counts as proof, so that signup skips the code.
    - A token that was handed back to the results page now gets a code. Its run is still saved as the first decision and opens once the code is in.
    - acceptsFirstDecisionHandoff is ignored.
  • Hardening.

  • - /auth/verify-email allows 10 tries per account per code lifetime.
    - A code can be used once only, and is looked up only within the signed-in account.
    - Both send endpoints wait a minute between codes.
    - A new code that collides with a live one is drawn again.
  • Frontend.

  • - /app, sign-in and the signed-in header send a pending session to /verify-email?send=1, which mails one fresh code. Sign-in does this before it looks at the subscription.
    - The verify page shows the address the code went to, has one "Send a new code" button and a "Wrong address? Sign out" link, and offers no skip to a new signup.
    - Calculator and signup copy no longer promises "no code".
  • Existing accounts are untouched. The column defaults to false, so no current account is gated, verified or not. The verify page still offers them "Skip for now".
  • Full write-up: docs/EMAIL_VERIFICATION.md. CLAUDE.md and the calculator and funnel docs are updated to match.

    Review follow-ups (9c931107)


  • Codex: a lapsed account can now verify, and checkout stays blocked while the trial grant runs. Both threads are resolved.

  • Cursor:

  • - The admin check now reads the account.
    - The stale tokenDisclosed comments in the two leads services are corrected.
    - The saved-run copy now says a code may be emailed. Only the server knows whether the token already proved the address.

    Deploy


  • Apply 20261129120000_add_email_verification_pending (a non-null boolean, default false) before the backend starts. Every authenticated query reads the column.

  • Ship the frontend with the backend. An older frontend doesn't read the flag, so it would show unverified users a workspace whose calls fail.

  • Check that every address in ADMIN_EMAILS already has a verified account.
  • Not covered


    Bots can still create user rows and still receive the code email. Only a challenge on the signup form, such as Cloudflare Turnstile, would stop that.

    Testing


    All run locally against Postgres with CI's environment, with GITHUB_RUN_ID set so the network-gated suites run too:
  • Backend unit: 3,746 passed.

  • Integration: 98 passed.

  • test:real-security: 28 passed. test:security: 39 passed.

  • Frontend: 1,098 passed.

  • Type-check and lint: no errors.
  • 🤖 Generated with Claude Code

    https://claude.ai/code/session_01DchAE7UPyYYujQjmL7SXwo

    Diff: 563 lines (+422 / -141) across 7 files Reviewer: ethanteng Review duration: 208m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 563 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.379
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #393"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.7% (MEDIUM) · Higher = larger blast radius
    49.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.5% · Safe to merge
    21.5%