fix:Anzeige Sperre
CI / audit (push) Skipped
CI / checks (push) Successful in 3m46s
CI / image (push) Successful in 1m11s

This commit is contained in:
marco.morath committed 2026-11-26 09:18:47 +01:00
1 parent d718543169
commit 675a8cd6f2
14 files changed
+388 -123

No files matched your search

+6
View File
@@ -159,6 +159,12 @@ Das entfernt alle zweiten Faktoren (Authenticator-App und Passkeys) und gibt
einen Link zum Setzen eines neuen Passworts aus (24 Stunden gültig). Für andere Benutzer geht das auch in der einen Link zum Setzen eines neuen Passworts aus (24 Stunden gültig). Für andere Benutzer geht das auch in der
Verwaltung unter *Benutzer → Anmeldung zurücksetzen*. Verwaltung unter *Benutzer → Anmeldung zurücksetzen*.
Nach fünf falschen Passwörtern in Folge ist ein Konto 15 Minuten gesperrt; die
Anmeldemeldung verrät das nicht. Die Benutzerliste zeigt das Konto dann als
„vorübergehend gesperrt“, die Seite des Benutzers Grund, Beginn und Ende der
Sperre. Mit *Sperre aufheben* kann sich die Person sofort wieder anmelden;
das steht im Protokoll.
### Formulare ### Formulare
Administratoren und Ersteller legen Formulare unter *Formulare* an. Ein Administratoren und Ersteller legen Formulare unter *Formulare* an. Ein
+5 -2
View File
@@ -85,7 +85,10 @@ produktive Instanz.
gesperrt“. Die Meldung ist bei falschem Passwort, gesperrtem und gesperrt“. Die Meldung ist bei falschem Passwort, gesperrtem und
unbekanntem Konto dieselbe – sie verrät nicht, ob das Konto existiert. unbekanntem Konto dieselbe – sie verrät nicht, ob das Konto existiert.
Nach 30 Fehlversuchen von derselben Adresse in 15 Minuten erscheint Nach 30 Fehlversuchen von derselben Adresse in 15 Minuten erscheint
„Zu viele Versuche“. „Zu viele Versuche“. In der Benutzerverwaltung steht das Konto als
„vorübergehend gesperrt“; die Seite des Benutzers nennt Grund, Beginn
und Ende der Sperre, „Sperre aufheben“ gibt es sofort frei (Protokoll:
„Sperre eines Kontos aufgehoben“).
- Formular-Link eines Formulars mit Zugriff „Ausgewählte Benutzer“ als nicht - Formular-Link eines Formulars mit Zugriff „Ausgewählte Benutzer“ als nicht
eingeladene Person öffnen: kein Zugriff. eingeladene Person öffnen: kein Zugriff.
- Antwort-ID einer fremden Antwort in die Adresse einsetzen: 404. - Antwort-ID einer fremden Antwort in die Adresse einsetzen: 404.
@@ -103,7 +106,7 @@ produktive Instanz.
| 26.11.2026 | Testinstanz, 2 Web-Prozesse | Lasttest (95 %) | bestanden | 20 gleichzeitige Abrufe, je 100: `/` 142 ms, `/login` 169 ms, `/f/<token>` 179 ms; einzeln ~30 ms; ~270 Abrufe/s | | 26.11.2026 | Testinstanz, 2 Web-Prozesse | Lasttest (95 %) | bestanden | 20 gleichzeitige Abrufe, je 100: `/` 142 ms, `/login` 169 ms, `/f/<token>` 179 ms; einzeln ~30 ms; ~270 Abrufe/s |
| 26.11.2026 | Testinstanz | Update mit Daten | bestanden mit Bemerkung | Neues Image (Debian-Updates, ohne pip) auf bestehende Daten: „Datenbank ist aktuell (0017_response_note)“, Formulare, Antworten, Gestaltung und Anmeldung unverändert. Kein Schemawechsel seit 0017; Migrationen mit Daten bei den Phasen-Updates erfolgt. Voller Weg mit `OLD_IMAGE` und Sicherung vor dem Update beim nächsten Release mit Migration | | 26.11.2026 | Testinstanz | Update mit Daten | bestanden mit Bemerkung | Neues Image (Debian-Updates, ohne pip) auf bestehende Daten: „Datenbank ist aktuell (0017_response_note)“, Formulare, Antworten, Gestaltung und Anmeldung unverändert. Kein Schemawechsel seit 0017; Migrationen mit Daten bei den Phasen-Updates erfolgt. Voller Weg mit `OLD_IMAGE` und Sicherung vor dem Update beim nächsten Release mit Migration |
| 26.11.2026 | Testinstanz | Wiederherstellung | bestanden | Manuelle Sicherung zurückgespielt: Stand der Sicherung vollständig (Formulare, Antworten, Medien, Gestaltung, Anmeldung); nach der Sicherung angelegtes Formular entfernt; nach der Sicherung gelöschtes Konto blieb durch das Löschjournal gelöscht | | 26.11.2026 | Testinstanz | Wiederherstellung | bestanden | Manuelle Sicherung zurückgespielt: Stand der Sicherung vollständig (Formulare, Antworten, Medien, Gestaltung, Anmeldung); nach der Sicherung angelegtes Formular entfernt; nach der Sicherung gelöschtes Konto blieb durch das Löschjournal gelöscht |
| | | Stichproben | | | | 26.11.2026 | Testinstanz | Stichproben | bestanden mit Bemerkung | Sperre nach Fehlversuchen greift, Meldung verrät nichts, „Zu viele Versuche“ je Adresse; fremde Formulare und Antworten nicht erreichbar; umbenannte Dateien abgelehnt. Bemerkung: Die Sperre war in der Benutzerverwaltung nicht zu sehen; ergänzt (Anzeige „vorübergehend gesperrt“, Grund und Ende, Aufheben durch Admins, `test_accounts`) |
### Bewertung ZAP Baseline (26.11.2026) ### Bewertung ZAP Baseline (26.11.2026)
+1
View File
@@ -73,6 +73,7 @@ ACTIONS = {
"form.history_restored", "form.history_restored",
"form.trash_restored", "form.trash_restored",
"admin.history_changed", "admin.history_changed",
"admin.user_unlocked",
} }
+14 -1
View File
@@ -130,7 +130,9 @@ def password_login(
if user.failed_logins >= LOCK_AFTER_FAILURES: if user.failed_logins >= LOCK_AFTER_FAILURES:
user.locked_until = now + LOCK_DURATION user.locked_until = now + LOCK_DURATION
user.failed_logins = 0 user.failed_logins = 0
audit.record(db, "auth.locked", target_type="user", target_id=user.id) audit.record(db, "auth.locked", target_type="user", target_id=user.id,
details={"attempts": LOCK_AFTER_FAILURES,
"minutes": int(LOCK_DURATION.total_seconds() // 60)})
return LoginResult(LoginOutcome.INVALID) return LoginResult(LoginOutcome.INVALID)
user.failed_logins = 0 user.failed_logins = 0
@@ -455,6 +457,17 @@ def create_user(
return user return user
def unlock(db: Session, admin: UserAccount, user: UserAccount) -> bool:
"""Sperre nach Fehlversuchen aufheben. False, wenn keine bestand."""
was_locked = user.is_locked
user.locked_until = None
user.failed_logins = 0
if was_locked:
audit.record(db, "admin.user_unlocked", actor_id=admin.id, target_type="user",
target_id=user.id)
return was_locked
def update_user( def update_user(
db: Session, db: Session,
admin: UserAccount, admin: UserAccount,
+61 -15
View File
@@ -4,7 +4,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Surveybox VERSION\n" "Project-Id-Version: Surveybox VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2026-11-26 08:43+0100\n" "POT-Creation-Date: 2026-11-26 09:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: de\n" "Language: de\n"
@@ -828,6 +828,10 @@ msgstr "Die Antwort wurde geändert und der Vermerk gespeichert."
msgid "All sessions of this user have been signed out." msgid "All sessions of this user have been signed out."
msgstr "Alle Sitzungen dieses Benutzers wurden abgemeldet." msgstr "Alle Sitzungen dieses Benutzers wurden abgemeldet."
#: surveybox/web/templating.py
msgid "The lock has been lifted. The user can sign in again."
msgstr "Die Sperre wurde aufgehoben. Der Benutzer kann sich wieder anmelden."
#: surveybox/web/templating.py #: surveybox/web/templating.py
msgid "The passkey has been added." msgid "The passkey has been added."
msgstr "Der Passkey wurde hinzugefügt." msgstr "Der Passkey wurde hinzugefügt."
@@ -1132,6 +1136,10 @@ msgstr "Gelöschtes Formular wiederhergestellt"
msgid "Form history settings changed" msgid "Form history settings changed"
msgstr "Einstellungen zu Verlauf und Papierkorb geändert" msgstr "Einstellungen zu Verlauf und Papierkorb geändert"
#: surveybox/web/routes/admin.py
msgid "Lock of an account lifted"
msgstr "Sperre eines Kontos aufgehoben"
#: surveybox/web/routes/admin.py #: surveybox/web/routes/admin.py
msgid "Account deleted" msgid "Account deleted"
msgstr "Konto gelöscht" msgstr "Konto gelöscht"
@@ -3133,8 +3141,9 @@ msgstr "Art"
msgid "Recipient" msgid "Recipient"
msgstr "Empfänger" msgstr "Empfänger"
#: surveybox/web/templates/admin_mail.html surveybox/web/templates/admin_users.html #: surveybox/web/templates/admin_mail.html surveybox/web/templates/admin_user_edit.html
#: surveybox/web/templates/followup_recipients.html surveybox/web/templates/forms_list.html #: surveybox/web/templates/admin_users.html surveybox/web/templates/followup_recipients.html
#: surveybox/web/templates/forms_list.html
msgid "Status" msgid "Status"
msgstr "Status" msgstr "Status"
@@ -3427,6 +3436,32 @@ msgstr "Benutzer jetzt löschen"
msgid "All users" msgid "All users"
msgstr "Alle Benutzer" msgstr "Alle Benutzer"
#: surveybox/web/templates/admin_user_edit.html
msgid "Temporarily locked"
msgstr "Vorübergehend gesperrt"
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "Reason: %(num)d failed sign-in attempts in a row."
msgstr "Grund: %(num)d fehlgeschlagene Anmeldeversuche in Folge."
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "Locked since %(since)s, until %(until)s. Until then, sign-in fails even with the right password."
msgstr ""
"Gesperrt seit %(since)s, bis %(until)s. Bis dahin scheitert die Anmeldung auch mit dem richtigen "
"Passwort."
#: surveybox/web/templates/admin_user_edit.html
msgid "Lift lock"
msgstr "Sperre aufheben"
#: surveybox/web/templates/admin_user_edit.html
msgid "If the attempts did not come from this person, reset the password instead and check the log."
msgstr ""
"Kamen die Versuche nicht von dieser Person, setzen Sie besser die Anmeldung zurück und prüfen Sie"
" das Protokoll."
#: surveybox/web/templates/admin_user_edit.html #: surveybox/web/templates/admin_user_edit.html
msgid "Account is active" msgid "Account is active"
msgstr "Konto ist aktiv" msgstr "Konto ist aktiv"
@@ -3435,6 +3470,29 @@ msgstr "Konto ist aktiv"
msgid "Last sign-in" msgid "Last sign-in"
msgstr "Letzte Anmeldung" msgstr "Letzte Anmeldung"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "deactivated"
msgstr "deaktiviert"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "temporarily locked"
msgstr "vorübergehend gesperrt"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "invited"
msgstr "eingeladen"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "active"
msgstr "aktiv"
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "%(num)d failed sign-in attempt since the last success"
msgid_plural "%(num)d failed sign-in attempts since the last success"
msgstr[0] "%(num)d fehlgeschlagener Anmeldeversuch seit der letzten erfolgreichen Anmeldung"
msgstr[1] "%(num)d fehlgeschlagene Anmeldeversuche seit der letzten erfolgreichen Anmeldung"
#: surveybox/web/templates/admin_user_edit.html #: surveybox/web/templates/admin_user_edit.html
#, python-format #, python-format
msgid "%(num)d passkey" msgid "%(num)d passkey"
@@ -3588,18 +3646,6 @@ msgstr "Suchen"
msgid "Search by name or email" msgid "Search by name or email"
msgstr "Nach Name oder E-Mail suchen" msgstr "Nach Name oder E-Mail suchen"
#: surveybox/web/templates/admin_users.html
msgid "deactivated"
msgstr "deaktiviert"
#: surveybox/web/templates/admin_users.html
msgid "invited"
msgstr "eingeladen"
#: surveybox/web/templates/admin_users.html
msgid "active"
msgstr "aktiv"
#: surveybox/web/templates/admin_users.html #: surveybox/web/templates/admin_users.html
msgid "No users found." msgid "No users found."
msgstr "Keine Benutzer gefunden." msgstr "Keine Benutzer gefunden."
+57 -15
View File
@@ -4,7 +4,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Surveybox VERSION\n" "Project-Id-Version: Surveybox VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2026-11-26 08:43+0100\n" "POT-Creation-Date: 2026-11-26 09:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n" "Language: en\n"
@@ -828,6 +828,10 @@ msgstr "The answer has been changed and the note saved."
msgid "All sessions of this user have been signed out." msgid "All sessions of this user have been signed out."
msgstr "All sessions of this user have been signed out." msgstr "All sessions of this user have been signed out."
#: surveybox/web/templating.py
msgid "The lock has been lifted. The user can sign in again."
msgstr "The lock has been lifted. The user can sign in again."
#: surveybox/web/templating.py #: surveybox/web/templating.py
msgid "The passkey has been added." msgid "The passkey has been added."
msgstr "The passkey has been added." msgstr "The passkey has been added."
@@ -1130,6 +1134,10 @@ msgstr "Deleted form restored"
msgid "Form history settings changed" msgid "Form history settings changed"
msgstr "Form history settings changed" msgstr "Form history settings changed"
#: surveybox/web/routes/admin.py
msgid "Lock of an account lifted"
msgstr "Lock of an account lifted"
#: surveybox/web/routes/admin.py #: surveybox/web/routes/admin.py
msgid "Account deleted" msgid "Account deleted"
msgstr "Account deleted" msgstr "Account deleted"
@@ -3114,8 +3122,9 @@ msgstr "Type"
msgid "Recipient" msgid "Recipient"
msgstr "Recipient" msgstr "Recipient"
#: surveybox/web/templates/admin_mail.html surveybox/web/templates/admin_users.html #: surveybox/web/templates/admin_mail.html surveybox/web/templates/admin_user_edit.html
#: surveybox/web/templates/followup_recipients.html surveybox/web/templates/forms_list.html #: surveybox/web/templates/admin_users.html surveybox/web/templates/followup_recipients.html
#: surveybox/web/templates/forms_list.html
msgid "Status" msgid "Status"
msgstr "Status" msgstr "Status"
@@ -3405,6 +3414,28 @@ msgstr "Delete user now"
msgid "All users" msgid "All users"
msgstr "All users" msgstr "All users"
#: surveybox/web/templates/admin_user_edit.html
msgid "Temporarily locked"
msgstr "Temporarily locked"
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "Reason: %(num)d failed sign-in attempts in a row."
msgstr "Reason: %(num)d failed sign-in attempts in a row."
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "Locked since %(since)s, until %(until)s. Until then, sign-in fails even with the right password."
msgstr "Locked since %(since)s, until %(until)s. Until then, sign-in fails even with the right password."
#: surveybox/web/templates/admin_user_edit.html
msgid "Lift lock"
msgstr "Lift lock"
#: surveybox/web/templates/admin_user_edit.html
msgid "If the attempts did not come from this person, reset the password instead and check the log."
msgstr "If the attempts did not come from this person, reset the password instead and check the log."
#: surveybox/web/templates/admin_user_edit.html #: surveybox/web/templates/admin_user_edit.html
msgid "Account is active" msgid "Account is active"
msgstr "Account is active" msgstr "Account is active"
@@ -3413,6 +3444,29 @@ msgstr "Account is active"
msgid "Last sign-in" msgid "Last sign-in"
msgstr "Last sign-in" msgstr "Last sign-in"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "deactivated"
msgstr "deactivated"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "temporarily locked"
msgstr "temporarily locked"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "invited"
msgstr "invited"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "active"
msgstr "active"
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "%(num)d failed sign-in attempt since the last success"
msgid_plural "%(num)d failed sign-in attempts since the last success"
msgstr[0] "%(num)d failed sign-in attempt since the last success"
msgstr[1] "%(num)d failed sign-in attempts since the last success"
#: surveybox/web/templates/admin_user_edit.html #: surveybox/web/templates/admin_user_edit.html
#, python-format #, python-format
msgid "%(num)d passkey" msgid "%(num)d passkey"
@@ -3564,18 +3618,6 @@ msgstr "Search"
msgid "Search by name or email" msgid "Search by name or email"
msgstr "Search by name or email" msgstr "Search by name or email"
#: surveybox/web/templates/admin_users.html
msgid "deactivated"
msgstr "deactivated"
#: surveybox/web/templates/admin_users.html
msgid "invited"
msgstr "invited"
#: surveybox/web/templates/admin_users.html
msgid "active"
msgstr "active"
#: surveybox/web/templates/admin_users.html #: surveybox/web/templates/admin_users.html
msgid "No users found." msgid "No users found."
msgstr "No users found." msgstr "No users found."
+61 -15
View File
@@ -4,7 +4,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Surveybox VERSION\n" "Project-Id-Version: Surveybox VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2026-11-26 08:43+0100\n" "POT-Creation-Date: 2026-11-26 09:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: fr\n" "Language: fr\n"
@@ -828,6 +828,10 @@ msgstr "La réponse a été modifiée et la note enregistrée."
msgid "All sessions of this user have been signed out." msgid "All sessions of this user have been signed out."
msgstr "Toutes les sessions de cet utilisateur ont été déconnectées." msgstr "Toutes les sessions de cet utilisateur ont été déconnectées."
#: surveybox/web/templating.py
msgid "The lock has been lifted. The user can sign in again."
msgstr "Le blocage a été levé. L’utilisateur peut de nouveau se connecter."
#: surveybox/web/templating.py #: surveybox/web/templating.py
msgid "The passkey has been added." msgid "The passkey has been added."
msgstr "La clé d’accès a été ajoutée." msgstr "La clé d’accès a été ajoutée."
@@ -1130,6 +1134,10 @@ msgstr "Formulaire supprimé restauré"
msgid "Form history settings changed" msgid "Form history settings changed"
msgstr "Paramètres de l’historique et de la corbeille modifiés" msgstr "Paramètres de l’historique et de la corbeille modifiés"
#: surveybox/web/routes/admin.py
msgid "Lock of an account lifted"
msgstr "Blocage d’un compte levé"
#: surveybox/web/routes/admin.py #: surveybox/web/routes/admin.py
msgid "Account deleted" msgid "Account deleted"
msgstr "Compte supprimé" msgstr "Compte supprimé"
@@ -3136,8 +3144,9 @@ msgstr "Type"
msgid "Recipient" msgid "Recipient"
msgstr "Destinataire" msgstr "Destinataire"
#: surveybox/web/templates/admin_mail.html surveybox/web/templates/admin_users.html #: surveybox/web/templates/admin_mail.html surveybox/web/templates/admin_user_edit.html
#: surveybox/web/templates/followup_recipients.html surveybox/web/templates/forms_list.html #: surveybox/web/templates/admin_users.html surveybox/web/templates/followup_recipients.html
#: surveybox/web/templates/forms_list.html
msgid "Status" msgid "Status"
msgstr "Statut" msgstr "Statut"
@@ -3435,6 +3444,32 @@ msgstr "Supprimer l’utilisateur maintenant"
msgid "All users" msgid "All users"
msgstr "Tous les utilisateurs" msgstr "Tous les utilisateurs"
#: surveybox/web/templates/admin_user_edit.html
msgid "Temporarily locked"
msgstr "Temporairement bloqué"
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "Reason: %(num)d failed sign-in attempts in a row."
msgstr "Motif : %(num)d tentatives de connexion échouées d’affilée."
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "Locked since %(since)s, until %(until)s. Until then, sign-in fails even with the right password."
msgstr ""
"Bloqué depuis le %(since)s, jusqu’au %(until)s. D’ici là, la connexion échoue même avec le bon "
"mot de passe."
#: surveybox/web/templates/admin_user_edit.html
msgid "Lift lock"
msgstr "Lever le blocage"
#: surveybox/web/templates/admin_user_edit.html
msgid "If the attempts did not come from this person, reset the password instead and check the log."
msgstr ""
"Si les tentatives ne venaient pas de cette personne, réinitialisez plutôt la connexion et "
"consultez le journal."
#: surveybox/web/templates/admin_user_edit.html #: surveybox/web/templates/admin_user_edit.html
msgid "Account is active" msgid "Account is active"
msgstr "Le compte est actif" msgstr "Le compte est actif"
@@ -3443,6 +3478,29 @@ msgstr "Le compte est actif"
msgid "Last sign-in" msgid "Last sign-in"
msgstr "Dernière connexion" msgstr "Dernière connexion"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "deactivated"
msgstr "désactivé"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "temporarily locked"
msgstr "temporairement bloqué"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "invited"
msgstr "invité"
#: surveybox/web/templates/admin_user_edit.html surveybox/web/templates/admin_users.html
msgid "active"
msgstr "actif"
#: surveybox/web/templates/admin_user_edit.html
#, python-format
msgid "%(num)d failed sign-in attempt since the last success"
msgid_plural "%(num)d failed sign-in attempts since the last success"
msgstr[0] "%(num)d tentative de connexion échouée depuis la dernière réussie"
msgstr[1] "%(num)d tentatives de connexion échouées depuis la dernière réussie"
#: surveybox/web/templates/admin_user_edit.html #: surveybox/web/templates/admin_user_edit.html
#, python-format #, python-format
msgid "%(num)d passkey" msgid "%(num)d passkey"
@@ -3598,18 +3656,6 @@ msgstr "Rechercher"
msgid "Search by name or email" msgid "Search by name or email"
msgstr "Rechercher par nom ou e-mail" msgstr "Rechercher par nom ou e-mail"
#: surveybox/web/templates/admin_users.html
msgid "deactivated"
msgstr "désactivé"
#: surveybox/web/templates/admin_users.html
msgid "invited"
msgstr "invité"
#: surveybox/web/templates/admin_users.html
msgid "active"
msgstr "actif"
#: surveybox/web/templates/admin_users.html #: surveybox/web/templates/admin_users.html
msgid "No users found." msgid "No users found."
msgstr "Aucun utilisateur trouvé." msgstr "Aucun utilisateur trouvé."
+123 -73
View File
@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PROJECT VERSION\n" "Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2026-11-26 08:43+0100\n" "POT-Creation-Date: 2026-11-26 09:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -206,7 +206,7 @@ msgstr ""
#: surveybox/web/templates/admin_group_edit.html:119 #: surveybox/web/templates/admin_group_edit.html:119
#: surveybox/web/templates/admin_user_new.html:14 #: surveybox/web/templates/admin_user_new.html:14
#: surveybox/web/templates/admin_users.html:18 #: surveybox/web/templates/admin_users.html:18
#: surveybox/web/templates/admin_users.html:47 #: surveybox/web/templates/admin_users.html:48
#: surveybox/web/templates/forgot.html:14 #: surveybox/web/templates/forgot.html:14
#: surveybox/web/templates/guest_links.html:13 #: surveybox/web/templates/guest_links.html:13
#: surveybox/web/templates/guest_links.html:28 #: surveybox/web/templates/guest_links.html:28
@@ -347,7 +347,7 @@ msgstr ""
#: surveybox/web/templates/admin_group_edit.html:117 #: surveybox/web/templates/admin_group_edit.html:117
#: surveybox/web/templates/admin_groups.html:19 #: surveybox/web/templates/admin_groups.html:19
#: surveybox/web/templates/admin_groups.html:39 #: surveybox/web/templates/admin_groups.html:39
#: surveybox/web/templates/admin_user_edit.html:12 #: surveybox/web/templates/admin_user_edit.html:23
#: surveybox/web/templates/admin_user_new.html:12 #: surveybox/web/templates/admin_user_new.html:12
#: surveybox/web/templates/admin_users.html:18 #: surveybox/web/templates/admin_users.html:18
#: surveybox/web/templates/register.html:16 #: surveybox/web/templates/register.html:16
@@ -897,78 +897,82 @@ msgid "All sessions of this user have been signed out."
msgstr "" msgstr ""
#: surveybox/web/templating.py:41 #: surveybox/web/templating.py:41
msgid "The passkey has been added." msgid "The lock has been lifted. The user can sign in again."
msgstr "" msgstr ""
#: surveybox/web/templating.py:42 #: surveybox/web/templating.py:42
msgid "The passkey has been removed." msgid "The passkey has been added."
msgstr "" msgstr ""
#: surveybox/web/templating.py:43 #: surveybox/web/templating.py:43
msgid "The group has been saved." msgid "The passkey has been removed."
msgstr "" msgstr ""
#: surveybox/web/templating.py:44 #: surveybox/web/templating.py:44
msgid "The group has been deleted." msgid "The group has been saved."
msgstr "" msgstr ""
#: surveybox/web/templating.py:45 #: surveybox/web/templating.py:45
msgid "The form has been saved." msgid "The group has been deleted."
msgstr "" msgstr ""
#: surveybox/web/templating.py:46 #: surveybox/web/templating.py:46
msgid "The form has been saved."
msgstr ""
#: surveybox/web/templating.py:47
msgid "The form has been deleted." msgid "The form has been deleted."
msgstr "" msgstr ""
#: surveybox/web/templating.py:48 #: surveybox/web/templating.py:49
msgid "" msgid ""
"The form has been moved to the trash. It can be restored there for a " "The form has been moved to the trash. It can be restored there for a "
"limited time." "limited time."
msgstr "" msgstr ""
#: surveybox/web/templating.py:50 #: surveybox/web/templating.py:51
msgid "The form has been restored from the trash." msgid "The form has been restored from the trash."
msgstr "" msgstr ""
#: surveybox/web/templating.py:51 #: surveybox/web/templating.py:52
msgid "The selected changes have been restored." msgid "The selected changes have been restored."
msgstr "" msgstr ""
#: surveybox/web/templating.py:52 #: surveybox/web/templating.py:53
msgid "The copy has been created. It is a draft." msgid "The copy has been created. It is a draft."
msgstr "" msgstr ""
#: surveybox/web/templating.py:54 #: surveybox/web/templating.py:55
msgid "" msgid ""
"The template has been saved. New forms can be created from it in the form" "The template has been saved. New forms can be created from it in the form"
" list." " list."
msgstr "" msgstr ""
#: surveybox/web/templating.py:56 #: surveybox/web/templating.py:57
msgid "The settings have been saved." msgid "The settings have been saved."
msgstr "" msgstr ""
#: surveybox/web/templating.py:57 #: surveybox/web/templating.py:58
msgid "Waiting messages are sent within the next minute." msgid "Waiting messages are sent within the next minute."
msgstr "" msgstr ""
#: surveybox/web/templating.py:58 #: surveybox/web/templating.py:59
msgid "Your notification settings have been saved." msgid "Your notification settings have been saved."
msgstr "" msgstr ""
#: surveybox/web/templating.py:59 #: surveybox/web/templating.py:60
msgid "The invitation has been sent by email." msgid "The invitation has been sent by email."
msgstr "" msgstr ""
#: surveybox/web/templating.py:60 #: surveybox/web/templating.py:61
msgid "A link to set a new password has been sent by email." msgid "A link to set a new password has been sent by email."
msgstr "" msgstr ""
#: surveybox/web/templating.py:61 #: surveybox/web/templating.py:62
msgid "Your account has been created. You can now sign in." msgid "Your account has been created. You can now sign in."
msgstr "" msgstr ""
#: surveybox/web/templating.py:63 #: surveybox/web/templating.py:64
msgid "" msgid ""
"The question has been deleted. Rules of other questions that referred to " "The question has been deleted. Rules of other questions that referred to "
"it were removed." "it were removed."
@@ -1211,54 +1215,58 @@ msgid "Form history settings changed"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:97 #: surveybox/web/routes/admin.py:97
msgid "Account deleted" msgid "Lock of an account lifted"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:98 #: surveybox/web/routes/admin.py:98
msgid "Own data downloaded" msgid "Account deleted"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:99 #: surveybox/web/routes/admin.py:99
msgid "Data of a user exported" msgid "Own data downloaded"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:100 #: surveybox/web/routes/admin.py:100
msgid "Data of a guest address exported" msgid "Data of a user exported"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:101 #: surveybox/web/routes/admin.py:101
msgid "Guest downloaded their data" msgid "Data of a guest address exported"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:102 #: surveybox/web/routes/admin.py:102
msgid "Logo changed" msgid "Guest downloaded their data"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:103 #: surveybox/web/routes/admin.py:103
msgid "Design changed" msgid "Logo changed"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:104 #: surveybox/web/routes/admin.py:104
msgid "Email template changed" msgid "Design changed"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:105 #: surveybox/web/routes/admin.py:105
msgid "Answers exported" msgid "Email template changed"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:106 #: surveybox/web/routes/admin.py:106
msgid "Answer deleted by a manager" msgid "Answers exported"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:107 #: surveybox/web/routes/admin.py:107
msgid "Answer changed by a manager" msgid "Answer deleted by a manager"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:108 #: surveybox/web/routes/admin.py:108
msgid "Answer changed by a manager"
msgstr ""
#: surveybox/web/routes/admin.py:109
msgid "Guest address and its answers deleted" msgid "Guest address and its answers deleted"
msgstr "" msgstr ""
#: surveybox/web/routes/admin.py:182 #: surveybox/web/routes/admin.py:183
msgid "A chosen group does not fit this user type." msgid "A chosen group does not fit this user type."
msgstr "" msgstr ""
@@ -2059,7 +2067,7 @@ msgstr ""
#: surveybox/web/templates/admin_settings.html:60 #: surveybox/web/templates/admin_settings.html:60
#: surveybox/web/templates/admin_settings.html:71 #: surveybox/web/templates/admin_settings.html:71
#: surveybox/web/templates/admin_settings.html:85 #: surveybox/web/templates/admin_settings.html:85
#: surveybox/web/templates/admin_user_edit.html:21 #: surveybox/web/templates/admin_user_edit.html:32
#: surveybox/web/templates/followup_edit.html:57 #: surveybox/web/templates/followup_edit.html:57
#: surveybox/web/templates/form_access.html:26 #: surveybox/web/templates/form_access.html:26
#: surveybox/web/templates/form_designer.html:50 #: surveybox/web/templates/form_designer.html:50
@@ -2436,7 +2444,7 @@ msgid "Change password"
msgstr "" msgstr ""
#: surveybox/web/templates/account.html:51 #: surveybox/web/templates/account.html:51
#: surveybox/web/templates/admin_user_edit.html:26 #: surveybox/web/templates/admin_user_edit.html:39
msgid "Two-factor authentication" msgid "Two-factor authentication"
msgstr "" msgstr ""
@@ -2499,7 +2507,7 @@ msgid "Add passkey"
msgstr "" msgstr ""
#: surveybox/web/templates/account.html:103 #: surveybox/web/templates/account.html:103
#: surveybox/web/templates/admin_user_edit.html:28 #: surveybox/web/templates/admin_user_edit.html:41
msgid "Authenticator app" msgid "Authenticator app"
msgstr "" msgstr ""
@@ -3066,7 +3074,7 @@ msgid "Person"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_group_edit.html:67 #: surveybox/web/templates/admin_group_edit.html:67
#: surveybox/web/templates/admin_user_edit.html:14 #: surveybox/web/templates/admin_user_edit.html:25
#: surveybox/web/templates/admin_user_new.html:16 #: surveybox/web/templates/admin_user_new.html:16
#: surveybox/web/templates/admin_users.html:18 #: surveybox/web/templates/admin_users.html:18
#: surveybox/web/templates/form_team.html:11 #: surveybox/web/templates/form_team.html:11
@@ -3152,7 +3160,7 @@ msgstr ""
#: surveybox/web/templates/admin_groups.html:2 #: surveybox/web/templates/admin_groups.html:2
#: surveybox/web/templates/admin_groups.html:15 #: surveybox/web/templates/admin_groups.html:15
#: surveybox/web/templates/admin_user_edit.html:32 #: surveybox/web/templates/admin_user_edit.html:45
#: surveybox/web/templates/admin_user_new.html:24 #: surveybox/web/templates/admin_user_new.html:24
#: surveybox/web/templates/base.html:48 surveybox/web/templates/base.html:52 #: surveybox/web/templates/base.html:48 surveybox/web/templates/base.html:52
#: surveybox/web/templates/form_access.html:11 #: surveybox/web/templates/form_access.html:11
@@ -3329,7 +3337,7 @@ msgid ""
msgstr "" msgstr ""
#: surveybox/web/templates/admin_mail.html:79 #: surveybox/web/templates/admin_mail.html:79
#: surveybox/web/templates/admin_user_edit.html:24 #: surveybox/web/templates/admin_user_edit.html:35
msgid "Created" msgid "Created"
msgstr "" msgstr ""
@@ -3343,6 +3351,7 @@ msgid "Recipient"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_mail.html:79 #: surveybox/web/templates/admin_mail.html:79
#: surveybox/web/templates/admin_user_edit.html:37
#: surveybox/web/templates/admin_users.html:19 #: surveybox/web/templates/admin_users.html:19
#: surveybox/web/templates/followup_recipients.html:18 #: surveybox/web/templates/followup_recipients.html:18
#: surveybox/web/templates/forms_list.html:9 #: surveybox/web/templates/forms_list.html:9
@@ -3596,7 +3605,7 @@ msgid ""
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_delete.html:3 #: surveybox/web/templates/admin_user_delete.html:3
#: surveybox/web/templates/admin_user_edit.html:72 #: surveybox/web/templates/admin_user_edit.html:85
msgid "Delete user" msgid "Delete user"
msgstr "" msgstr ""
@@ -3629,90 +3638,143 @@ msgstr ""
msgid "All users" msgid "All users"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:20 #: surveybox/web/templates/admin_user_edit.html:12
msgid "Temporarily locked"
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:13
#, python-format
msgid "Reason: %(num)d failed sign-in attempts in a row."
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:14
#, python-format
msgid ""
"Locked since %(since)s, until %(until)s. Until then, sign-in fails even "
"with the right password."
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:16
msgid "Lift lock"
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:18
msgid ""
"If the attempts did not come from this person, reset the password instead"
" and check the log."
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:31
msgid "Account is active" msgid "Account is active"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:25 #: surveybox/web/templates/admin_user_edit.html:36
#: surveybox/web/templates/admin_users.html:19 #: surveybox/web/templates/admin_users.html:19
msgid "Last sign-in" msgid "Last sign-in"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:29 #: surveybox/web/templates/admin_user_edit.html:38
#: surveybox/web/templates/admin_users.html:29
msgid "deactivated"
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:38
#: surveybox/web/templates/admin_users.html:30
msgid "temporarily locked"
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:38
#: surveybox/web/templates/admin_users.html:31
msgid "invited"
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:38
#: surveybox/web/templates/admin_users.html:32
msgid "active"
msgstr ""
#: surveybox/web/templates/admin_user_edit.html:38
#, python-format
msgid "%(num)d failed sign-in attempt since the last success"
msgid_plural "%(num)d failed sign-in attempts since the last success"
msgstr[0] ""
msgstr[1] ""
#: surveybox/web/templates/admin_user_edit.html:42
#, python-format #, python-format
msgid "%(num)d passkey" msgid "%(num)d passkey"
msgid_plural "%(num)d passkeys" msgid_plural "%(num)d passkeys"
msgstr[0] "" msgstr[0] ""
msgstr[1] "" msgstr[1] ""
#: surveybox/web/templates/admin_user_edit.html:30 #: surveybox/web/templates/admin_user_edit.html:43
msgid "off" msgid "off"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:38 #: surveybox/web/templates/admin_user_edit.html:51
msgid "Reset sign-in" msgid "Reset sign-in"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:38 #: surveybox/web/templates/admin_user_edit.html:51
msgid "Invitation link" msgid "Invitation link"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:41 #: surveybox/web/templates/admin_user_edit.html:54
msgid "" msgid ""
"Creates a one-time link with which the person sets a new password. Valid " "Creates a one-time link with which the person sets a new password. Valid "
"for 24 hours." "for 24 hours."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:43 #: surveybox/web/templates/admin_user_edit.html:56
msgid "" msgid ""
"Creates a new invitation link. Valid for 7 days; earlier links become " "Creates a new invitation link. Valid for 7 days; earlier links become "
"invalid." "invalid."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:49 #: surveybox/web/templates/admin_user_edit.html:62
msgid "" msgid ""
"Also remove all second factors: authenticator app and passkeys (for " "Also remove all second factors: authenticator app and passkeys (for "
"example if the device was lost)" "example if the device was lost)"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:52 #: surveybox/web/templates/admin_user_edit.html:65
msgid "Send link by email" msgid "Send link by email"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:53 #: surveybox/web/templates/admin_user_edit.html:66
msgid "Create link and show it" msgid "Create link and show it"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:55 #: surveybox/web/templates/admin_user_edit.html:68
#, python-format #, python-format
msgid "By email, the link goes to %(address)s and is not shown here." msgid "By email, the link goes to %(address)s and is not shown here."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:59 #: surveybox/web/templates/admin_user_edit.html:72
msgid "Sign out all sessions of this user" msgid "Sign out all sessions of this user"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:63 #: surveybox/web/templates/admin_user_edit.html:76
msgid "Data of this user" msgid "Data of this user"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:64 #: surveybox/web/templates/admin_user_edit.html:77
msgid "" msgid ""
"For a request for access: everything stored about this person, as a JSON " "For a request for access: everything stored about this person, as a JSON "
"file. The export is recorded in the log." "file. The export is recorded in the log."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:67 #: surveybox/web/templates/admin_user_edit.html:80
msgid "Export data" msgid "Export data"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:73 #: surveybox/web/templates/admin_user_edit.html:86
msgid "" msgid ""
"Deletes the account with all its data. You see beforehand exactly what " "Deletes the account with all its data. You see beforehand exactly what "
"will be deleted and decide what happens to the forms of this user." "will be deleted and decide what happens to the forms of this user."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_user_edit.html:74 #: surveybox/web/templates/admin_user_edit.html:87
msgid "Delete user …" msgid "Delete user …"
msgstr "" msgstr ""
@@ -3796,34 +3858,22 @@ msgstr ""
msgid "Search by name or email" msgid "Search by name or email"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_users.html:29 #: surveybox/web/templates/admin_users.html:38
msgid "deactivated"
msgstr ""
#: surveybox/web/templates/admin_users.html:30
msgid "invited"
msgstr ""
#: surveybox/web/templates/admin_users.html:31
msgid "active"
msgstr ""
#: surveybox/web/templates/admin_users.html:37
msgid "No users found." msgid "No users found."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_users.html:43 #: surveybox/web/templates/admin_users.html:44
msgid "Export the data of a guest" msgid "Export the data of a guest"
msgstr "" msgstr ""
#: surveybox/web/templates/admin_users.html:44 #: surveybox/web/templates/admin_users.html:45
msgid "" msgid ""
"For a request for access by someone who took part as a guest: everything " "For a request for access by someone who took part as a guest: everything "
"stored for this email address, as a JSON file. The export is recorded in " "stored for this email address, as a JSON file. The export is recorded in "
"the log." "the log."
msgstr "" msgstr ""
#: surveybox/web/templates/admin_users.html:49 #: surveybox/web/templates/admin_users.html:50
#: surveybox/web/templates/form_responses.html:152 #: surveybox/web/templates/form_responses.html:152
msgid "Export" msgid "Export"
msgstr "" msgstr ""
+6 -1
View File
@@ -4,7 +4,7 @@
from __future__ import annotations from __future__ import annotations
import uuid import uuid
from datetime import datetime from datetime import UTC, datetime
from enum import StrEnum from enum import StrEnum
from typing import Any from typing import Any
@@ -113,6 +113,11 @@ class UserAccount(Base):
def has_second_factor(self) -> bool: def has_second_factor(self) -> bool:
return self.has_totp or self.has_passkey return self.has_totp or self.has_passkey
@property
def is_locked(self) -> bool:
"""Nach zu vielen Fehlversuchen vorübergehend gesperrt (siehe accounts.service)."""
return self.locked_until is not None and self.locked_until > datetime.now(UTC)
@property @property
def is_admin(self) -> bool: def is_admin(self) -> bool:
return self.role == Role.ADMIN return self.role == Role.ADMIN
+16
View File
@@ -94,6 +94,7 @@ ACTION_NAMES: dict[str, str] = {
"form.history_restored": N_("Changes restored from the form history"), "form.history_restored": N_("Changes restored from the form history"),
"form.trash_restored": N_("Deleted form restored"), "form.trash_restored": N_("Deleted form restored"),
"admin.history_changed": N_("Form history settings changed"), "admin.history_changed": N_("Form history settings changed"),
"admin.user_unlocked": N_("Lock of an account lifted"),
"account.deleted": N_("Account deleted"), "account.deleted": N_("Account deleted"),
"account.exported": N_("Own data downloaded"), "account.exported": N_("Own data downloaded"),
"admin.user_exported": N_("Data of a user exported"), "admin.user_exported": N_("Data of a user exported"),
@@ -221,6 +222,9 @@ def _edit_page(request: Request, db: Db, target: UserAccount, **extra: Any) -> R
"target": target, "target": target,
"role_names": ROLE_NAMES, "role_names": ROLE_NAMES,
"groups": groups.groups_of(db, target), "groups": groups.groups_of(db, target),
"lock_attempts": service.LOCK_AFTER_FAILURES,
"lock_since": (target.locked_until - service.LOCK_DURATION
if target.is_locked and target.locked_until else None),
**extra, **extra,
}, },
status_code=status_code, status_code=status_code,
@@ -401,6 +405,18 @@ def create_user_link(
) )
@router.post("/users/{public_id}/unlock")
def unlock_user(db: Db, auth: AdminUser, public_id: str) -> Response:
"""Vorübergehende Sperre nach Fehlversuchen aufheben."""
target = _load_user(db, public_id)
if target is None:
return RedirectResponse("/admin/users", status_code=303)
service.unlock(db, auth.user, target)
db.commit()
return RedirectResponse(f"/admin/users/{target.public_id}?notice=user_unlocked",
status_code=303)
@router.post("/users/{public_id}/sessions") @router.post("/users/{public_id}/sessions")
def revoke_user_sessions(db: Db, auth: AdminUser, public_id: str) -> Response: def revoke_user_sessions(db: Db, auth: AdminUser, public_id: str) -> Response:
target = _load_user(db, public_id) target = _load_user(db, public_id)
@@ -7,6 +7,17 @@
<h1>{{ target.display_name }}</h1> <h1>{{ target.display_name }}</h1>
<p class="readonly">{{ target.email }}</p> <p class="readonly">{{ target.email }}</p>
{% if error %}<p class="alert error" role="alert">{{ _(error) }}</p>{% endif %} {% if error %}<p class="alert error" role="alert">{{ _(error) }}</p>{% endif %}
{% if target.is_locked %}
<div class="alert warn" role="status">
<p><strong>{{ _('Temporarily locked') }}</strong></p>
<p>{{ _('Reason: %(num)d failed sign-in attempts in a row.', num=lock_attempts) }}
{{ _('Locked since %(since)s, until %(until)s. Until then, sign-in fails even with the right password.', since=lock_since | datetime, until=target.locked_until | datetime) }}</p>
<form method="post" action="/admin/users/{{ target.public_id }}/unlock">
{{ csrf_field(request) }}<button type="submit" class="secondary">{{ _('Lift lock') }}</button>
</form>
<p class="hint">{{ _('If the attempts did not come from this person, reset the password instead and check the log.') }}</p>
</div>
{% endif %}
<form method="post" action="/admin/users/{{ target.public_id }}" class="form"> <form method="post" action="/admin/users/{{ target.public_id }}" class="form">
{{ csrf_field(request) }} {{ csrf_field(request) }}
<label for="display_name">{{ _('Name') }}</label> <label for="display_name">{{ _('Name') }}</label>
@@ -23,6 +34,8 @@
<dl class="status"> <dl class="status">
<dt>{{ _('Created') }}</dt><dd>{{ target.created_at | datetime }}</dd> <dt>{{ _('Created') }}</dt><dd>{{ target.created_at | datetime }}</dd>
<dt>{{ _('Last sign-in') }}</dt><dd>{{ target.last_login_at | datetime }}</dd> <dt>{{ _('Last sign-in') }}</dt><dd>{{ target.last_login_at | datetime }}</dd>
<dt>{{ _('Status') }}</dt>
<dd>{% if not target.is_active %}{{ _('deactivated') }}{% elif target.is_locked %}{{ _('temporarily locked') }}{% elif not target.password_hash %}{{ _('invited') }}{% else %}{{ _('active') }}{% endif %}{% if target.failed_logins and not target.is_locked %} · {{ ngettext('%(num)d failed sign-in attempt since the last success', '%(num)d failed sign-in attempts since the last success', target.failed_logins) }}{% endif %}</dd>
<dt>{{ _('Two-factor authentication') }}</dt> <dt>{{ _('Two-factor authentication') }}</dt>
<dd> <dd>
{% if target.has_totp %}{{ _('Authenticator app') }}{% endif %} {% if target.has_totp %}{{ _('Authenticator app') }}{% endif %}
+1
View File
@@ -27,6 +27,7 @@
<td>{{ _(role_names[u.role]) }}</td> <td>{{ _(role_names[u.role]) }}</td>
<td> <td>
{% if not u.is_active %}<span class="badge muted">{{ _('deactivated') }}</span> {% if not u.is_active %}<span class="badge muted">{{ _('deactivated') }}</span>
{% elif u.is_locked %}<span class="badge warn">{{ _('temporarily locked') }}</span>
{% elif not u.password_hash %}<span class="badge">{{ _('invited') }}</span> {% elif not u.password_hash %}<span class="badge">{{ _('invited') }}</span>
{% else %}<span class="badge ok">{{ _('active') }}</span>{% endif %} {% else %}<span class="badge ok">{{ _('active') }}</span>{% endif %}
{% if u.has_second_factor %}<span class="badge">2FA</span>{% endif %} {% if u.has_second_factor %}<span class="badge">2FA</span>{% endif %}
+1
View File
@@ -38,6 +38,7 @@ NOTICES: dict[str, str] = {
"response_deleted": N_("The answer has been deleted."), "response_deleted": N_("The answer has been deleted."),
"response_edited": N_("The answer has been changed and the note saved."), "response_edited": N_("The answer has been changed and the note saved."),
"user_sessions_revoked": N_("All sessions of this user have been signed out."), "user_sessions_revoked": N_("All sessions of this user have been signed out."),
"user_unlocked": N_("The lock has been lifted. The user can sign in again."),
"passkey_added": N_("The passkey has been added."), "passkey_added": N_("The passkey has been added."),
"passkey_removed": N_("The passkey has been removed."), "passkey_removed": N_("The passkey has been removed."),
"group_saved": N_("The group has been saved."), "group_saved": N_("The group has been saved."),
+23 -1
View File
@@ -64,7 +64,29 @@ def test_wrong_password_and_lockout(client: TestClient) -> None:
assert resp.status_code == 400 assert resp.status_code == 400
with Session(db.get_engine()) as s: with Session(db.get_engine()) as s:
user = s.scalar(select(UserAccount).where(UserAccount.email == "anna@example.de")) user = s.scalar(select(UserAccount).where(UserAccount.email == "anna@example.de"))
assert user is not None and user.locked_until is not None assert user is not None and user.locked_until is not None and user.is_locked
def test_admin_sees_and_lifts_lock(app) -> None: # type: ignore[no-untyped-def]
from test_mail import admin
target, _ = make_user(Role.PARTICIPANT, "paula@example.de")
guest = new_client(app)
for _ in range(5):
assert login(guest, "paula@example.de", "falsches passwort!!").status_code == 400
root = admin(app)
listing = root.get("/admin/users").text
assert "temporarily locked" in listing
page = root.get(f"/admin/users/{target.public_id}").text
assert "5 failed sign-in attempts in a row" in page and "Lift lock" in page
resp = root.post(f"/admin/users/{target.public_id}/unlock",
data={"csrf_token": csrf_from(page)})
assert resp.status_code == 303 and "user_unlocked" in resp.headers["location"]
assert "Lift lock" not in root.get(f"/admin/users/{target.public_id}").text
assert login(guest, "paula@example.de").status_code == 303
with Session(db.get_engine()) as s:
actions = list(s.scalars(select(AuditEvent.action)))
assert "auth.locked" in actions and "admin.user_unlocked" in actions
def test_unknown_user_gets_same_answer(client: TestClient) -> None: def test_unknown_user_gets_same_answer(client: TestClient) -> None: