Chore: Sprint32-36 Zwischenstand — alle Änderungen aus dieser Session committen
This commit is contained in:
parent
f4052fbb7d
commit
747c353444
20 changed files with 3115 additions and 63 deletions
|
|
@ -356,11 +356,15 @@ async def list_users(
|
|||
# ------------------------------------------------------------------
|
||||
@router.patch("/users/{uid}")
|
||||
async def patch_user(uid: int, data: UserPatch, user=Depends(require_mod)):
|
||||
# Rollenwechsel nur für Admins
|
||||
# Rollenwechsel + Privileg-Flags nur für Admins
|
||||
if data.rolle is not None and user["rolle"] != "admin":
|
||||
raise HTTPException(403, "Rollenwechsel nur für Admins.")
|
||||
if data.rolle and data.rolle not in ("user", "moderator", "admin"):
|
||||
raise HTTPException(400, "Ungültige Rolle.")
|
||||
if data.is_moderator is not None and user["rolle"] != "admin":
|
||||
raise HTTPException(403, "is_moderator darf nur von Admins geändert werden.")
|
||||
if data.is_social_media is not None and user["rolle"] != "admin":
|
||||
raise HTTPException(403, "is_social_media darf nur von Admins geändert werden.")
|
||||
|
||||
with db() as conn:
|
||||
target = conn.execute("SELECT id, rolle, name FROM users WHERE id=?", (uid,)).fetchone()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue