Sprint 14: User-Profil-System (bio, wohnort, erfahrung, avatar)

- DB-Migrationen: 7 neue Spalten in users (bio, wohnort, erfahrung, social_link, profil_sichtbarkeit, avatar_url, email_verified)
- GET /api/auth/me gibt nun alle Profil-Felder + created_at zurück
- PATCH /api/profile: Profil-Felder aktualisieren (mit Validierung)
- POST /api/profile/avatar: Avatar-Upload (PIL JPEG-Konvertierung, HEIC-Support)
- Router in main.py registriert
This commit is contained in:
rene 2026-04-17 09:18:53 +02:00
parent 41c4ba3dd6
commit 9bd8701a1d
4 changed files with 134 additions and 7 deletions

View file

@ -92,10 +92,16 @@ async def logout(response: Response):
@router.get("/me")
async def me(user=Depends(get_current_user)):
return {
"id": user["id"],
"name": user["name"],
"email": user["email"],
"rolle": user["rolle"],
"is_premium": bool(user["is_premium"]),
}
with db() as conn:
row = conn.execute(
"""SELECT id, name, email, rolle, is_premium, email_verified,
bio, wohnort, erfahrung, social_link,
profil_sichtbarkeit, avatar_url, created_at
FROM users WHERE id=?""",
(user["id"],)
).fetchone()
if not row:
raise HTTPException(404, "User nicht gefunden.")
data = dict(row)
data["is_premium"] = bool(data["is_premium"])
return data