feat(api): accept recovery codes as second factor and let users regenerate them

Enabling TOTP returns ten codes that are shown once. Disabling TOTP and
regenerating codes require the password plus a current code.

Closes #40

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:35:20 +01:00
1 parent dbea42e7a5
commit 7b063d2cd8
12 files changed
+510 -123

No files matched your search

+5
View File
@@ -149,6 +149,11 @@ func TestT(t *testing.T) {
if got, want := T(ctx, "error.password_too_short", "Min", 12), "Das Passwort braucht mindestens 12 Zeichen."; got != want {
t.Errorf("T(de, password_too_short) = %q, want %q", got, want)
}
for n, want := range map[int]string{1: "1 Wiederherstellungscode übrig", 3: "3 Wiederherstellungscodes übrig"} {
if got := T(ctx, "security.recovery.left", "Count", n); got != want {
t.Errorf("T(de, recovery.left, %d) = %q, want %q", n, got, want)
}
}
if got, want := T(ctx, "no.such.key"), "no.such.key"; got != want {
t.Errorf("T(missing) = %q, want %q", got, want)
}
+9 -2
View File
@@ -11,7 +11,7 @@
"auth.login.submit": "Weiter",
"auth.login.title": "Anmelden",
"auth.login.to_signup": "Registrieren",
"auth.login.totp_hint": "Code aus der Authenticator-App eingeben.",
"auth.login.totp_hint": "Code aus der Authenticator-App oder einen Wiederherstellungscode eingeben.",
"auth.signup.submit": "Anlegen",
"auth.signup.title": "Konto anlegen",
"auth.signup.to_login": "Zur Anmeldung",
@@ -61,6 +61,13 @@
"error.unsupported_locale": "Sprache wird nicht unterstützt.",
"lang.de": "Deutsch",
"lang.en": "English",
"security.recovery.left": {
"one": "{{.Count}} Wiederherstellungscode übrig",
"other": "{{.Count}} Wiederherstellungscodes übrig"
},
"security.recovery.regenerate": "Neue Wiederherstellungscodes erzeugen",
"security.recovery.save_now": "Bewahre diese Wiederherstellungscodes sicher auf. Jeder funktioniert einmal, falls du deinen Authenticator verlierst. Sie werden nicht erneut angezeigt.",
"security.recovery.saved": "Ich habe sie gespeichert",
"security.sso.heading": "Single Sign-on",
"security.sso.link": "SSO-Anmeldung verknüpfen",
"security.sso.linked": "SSO-Anmeldung verknüpft.",
@@ -69,7 +76,7 @@
"security.totp.active": "aktiv",
"security.totp.app_code": "Code aus der App",
"security.totp.confirm": "Bestätigen",
"security.totp.current_code": "Aktueller Code",
"security.totp.current_code": "Aktueller Code oder Wiederherstellungscode",
"security.totp.disable": "Deaktivieren",
"security.totp.heading": "Zwei-Faktor (TOTP)",
"security.totp.inactive": "nicht eingerichtet",
+9 -2
View File
@@ -11,7 +11,7 @@
"auth.login.submit": "Continue",
"auth.login.title": "Sign in",
"auth.login.to_signup": "Sign up",
"auth.login.totp_hint": "Enter the code from your authenticator app.",
"auth.login.totp_hint": "Enter the code from your authenticator app or one of your recovery codes.",
"auth.signup.submit": "Create",
"auth.signup.title": "Create account",
"auth.signup.to_login": "Back to sign in",
@@ -61,6 +61,13 @@
"error.unsupported_locale": "Unsupported language.",
"lang.de": "Deutsch",
"lang.en": "English",
"security.recovery.left": {
"one": "{{.Count}} recovery code left",
"other": "{{.Count}} recovery codes left"
},
"security.recovery.regenerate": "Generate new recovery codes",
"security.recovery.save_now": "Store these recovery codes somewhere safe. Each works once if you lose your authenticator. They will not be shown again.",
"security.recovery.saved": "I have saved them",
"security.sso.heading": "Single sign-on",
"security.sso.link": "Link SSO sign-in",
"security.sso.linked": "SSO sign-in linked.",
@@ -69,7 +76,7 @@
"security.totp.active": "active",
"security.totp.app_code": "Code from the app",
"security.totp.confirm": "Confirm",
"security.totp.current_code": "Current code",
"security.totp.current_code": "Current code or recovery code",
"security.totp.disable": "Disable",
"security.totp.heading": "Two-factor (TOTP)",
"security.totp.inactive": "not set up",