fix(auth): defer account creation until 2FA enrollment completes #119
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/2fa-before-registration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When the deployment requires 2FA (LETS_CHAT_SECRET_KEY set), POST /register no longer creates the user row up front. It validates the form, hashes the password, generates a TOTP secret, and stores the bundle in a new pending_registrations table keyed by a short-lived cookie. The user is redirected to /register/2fa which renders the QR/code form; a successful TOTP verification at POST /register/2fa is what actually creates the users row, sets the email, applies the digest default, runs the first-user promotion, and issues the session. Abandoning the flow now leaves no account behind (and no verification email already in flight) instead of squatting the username forever.
Touches the migration list (0015_pending_registrations.sql) so every hand-rolled setup_auth_pool in server/tests/ was patched to include it - per CLAUDE.md's migration-drift guidance.