Close medium exposure on reports, registration, uploads, and exercise HTML.
Deploy Development / deploy (push) Successful in 59s
Test Suite / pytest-backend (push) Failing after 47s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 17s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Failing after 7m48s

A superadmin can also turn off another account''s two-factor when the authenticator is lost.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-13 16:47:57 +02:00
1 parent 5ea225ec6b
commit f10c28e5cd
20 files changed
+480 -247

No files matched your search

+33
View File
@@ -283,6 +283,39 @@ def management_password_reset(
return {"ok": True, "mode": "email", "email_sent": bool(sent)}
@router.post("/profiles/{pid}/totp-reset")
def management_totp_reset(pid: str, tenant: TenantContext = Depends(get_tenant_context)):
"""Superadmin schaltet Zwei-Faktor ab, wenn der Nutzer den Authenticator nicht mehr hat."""
if not is_superadmin(tenant.global_role or ""):
raise HTTPException(status_code=403, detail="Nur Super-Admins")
try:
target = int(pid)
except ValueError:
raise HTTPException(status_code=400, detail="Ungültige Profil-ID")
if target == int(tenant.profile_id):
raise HTTPException(status_code=400, detail="Eigenen Zwei-Faktor unter Einstellungen ändern")
with get_db() as conn:
cur = get_cursor(conn)
cur.execute("SELECT id, totp_enabled FROM profiles WHERE id=%s", (target,))
row = cur.fetchone()
if not row:
raise HTTPException(status_code=404, detail="Profil nicht gefunden")
if not row.get("totp_enabled"):
return {"ok": True, "totp_enabled": False, "changed": False}
cur.execute(
"""
UPDATE profiles
SET totp_enabled=FALSE, totp_secret=NULL, totp_pending_secret=NULL, updated_at=NOW()
WHERE id=%s
""",
(target,),
)
cur.execute("DELETE FROM profile_recovery_codes WHERE profile_id=%s", (target,))
revoke_profile_sessions(cur, target)
return {"ok": True, "totp_enabled": False, "changed": True}
@router.get("/profiles/{pid}")
def get_profile(pid: str, session=Depends(require_auth)):
"""Profil nach ID — nur eigenes Profil oder Plattform-Admin (wie PUT)."""