fix: notify the account holder on duplicate email signup

GU
4mo ago
+308-3

Signing up with an email that already has an account showed "check your email" and sent nothing — Better Auth answers a duplicate sign-up with a synthetic 200 rather than an error whenever requireEmailVerification is on (which it is in cloud), so the frontend's already-exists branch never fired and no mail was triggered.

This wires emailAndPassword.onExistingUserSignUp so the existing account holder gets a new ExistingAccountEmail with a sign-in button and a reset-password link, and softens the confirmation-screen copy so it's true in both branches. The anti-enumeration response is deliberately kept intact — whoever submitted the form still learns nothing — and the unreachable-in-cloud error branch stays because it still fires in dev and on self-hosted installs with no email provider.

Verified against a real backend on a fresh Postgres in production config with outbound HTTP tapped: two signups with the same address returned identical 200s and produced exactly one mail each ("Verify your email address", then "You already have a Manifest account"), addressed to the account holder's real name, leaving a single user row. Backend (7560) and frontend (3986) suites pass, auth.instance.ts stays at 100% line and function coverage.


Summary by cubic

Notify the account holder when someone signs up with an email that already has an account, sending a sign-in button and reset link. This removes the “check your email” dead end while preserving the 200 anti-enumeration response.

  • Bug Fixes
    • Hooked emailAndPassword.onExistingUserSignUp to render and send ExistingAccountEmail with sign-in and reset links.
    • Built URLs from BETTER_AUTH_URL when set, falling back to http://localhost:${PORT}.
    • Updated register success copy to cover both verification and existing-account cases.