Events 2.3.0 (phase 1c): two-factor with an authenticator app, recovery codes

- TOTP (RFC 6238) next to email and WhatsApp: QR code and key to set up,
  the app's first code confirms it, a code can't be used twice, nothing
  is sent. The secret is stored encrypted.
- 10 single-use recovery codes whenever two-factor is turned on, shown
  once; accepted at sign-in in place of any code; a new set on request.
- Admins see each account's method; Reset 2FA clears the app and codes.
- Profile & Security, sign-in and Users pages; API types; 10 new tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 14:55:22 +02:00
co-authored by Claude Opus 5.5
parent b207d17db8
commit ee65ff358c
18 changed files with 815 additions and 60 deletions
+4 -1
View File
@@ -26,7 +26,7 @@ export type AuthResponse = AuthUser & {
deviceToken?: string;
};
export type TwoFactorMethod = "email" | "whatsapp";
export type TwoFactorMethod = "email" | "whatsapp" | "authenticator";
// What the login endpoint returns instead of a token when the account has 2FA on:
// a code was sent to `destination` (masked) and must be exchanged for the token.
@@ -37,6 +37,9 @@ export type TwoFactorChallenge = {
destination: string;
// The role requires 2FA and it wasn't on yet: verifying this code turns it on.
enrolling?: boolean;
// 2.3.0, setting up an authenticator app: the key and its otpauth:// link (shown as a QR code).
secret?: string;
otpauthUrl?: string;
};
export function isTwoFactorChallenge(res: unknown): res is TwoFactorChallenge {