corrections mineures des fichiers api/v1/auth.py et services/auth_service.py
parent
57ff496844
commit
89d3285ea6
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue