From 89d3285ea6a384ff589e957454cbb2879f719711 Mon Sep 17 00:00:00 2001 From: Anaz Date: Tue, 25 Feb 2025 15:23:25 +0400 Subject: [PATCH] corrections mineures des fichiers api/v1/auth.py et services/auth_service.py --- api/v1/auth.py | 2 +- services/auth_service.py | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/api/v1/auth.py b/api/v1/auth.py index d6287fe..dc19b31 100644 --- a/api/v1/auth.py +++ b/api/v1/auth.py @@ -61,7 +61,7 @@ async def verify_token(token: str = Body(...)): ) @router.get("/me", summary="Get current user") -async def read_users_me(token: str = Body(...)): +async def read_users_me(token: str = Depends(oauth2_scheme)): async with get_db() as db: return await AuthService.get_current_user(token, db) diff --git a/services/auth_service.py b/services/auth_service.py index 8372dbb..668caab 100644 --- a/services/auth_service.py +++ b/services/auth_service.py @@ -119,17 +119,20 @@ class AuthService: role_result = await db.execute(role_query) role_data = role_result.mappings().all() - - role = { - "id": role_data[0]["id"], - "name": role_data[0]["name"], - "permissions": [r["permission"] for r in role_data] - } + if not role_data: + role = user["role"] + else: + role = { + "id": role_data[0]["id"], + "name": role_data[0]["name"], + "permissions": [r["permission"] for r in role_data] + } # Préparez la réponse avec tous les champs requis return { "id": user["id"], "email": user["email"], + "hashed_password": user["hashed_password"], "full_name": user["full_name"], "phone": user["phone"], "date_of_birth": user["date_of_birth"].isoformat(),