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:
parent
41c4ba3dd6
commit
9bd8701a1d
4 changed files with 134 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue