Spaces:
Sleeping
Sleeping
Update api/routes/auth.py
Browse files- api/routes/auth.py +19 -10
api/routes/auth.py
CHANGED
|
@@ -123,17 +123,26 @@ async def login(form_data: OAuth2PasswordRequestForm = Depends()):
|
|
| 123 |
|
| 124 |
@router.get("/me")
|
| 125 |
async def get_me(current_user: dict = Depends(get_current_user)):
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
"
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
-
|
|
|
|
| 137 |
|
| 138 |
# Export the router as 'auth' for api.__init__.py
|
| 139 |
auth = router
|
|
|
|
| 123 |
|
| 124 |
@router.get("/me")
|
| 125 |
async def get_me(current_user: dict = Depends(get_current_user)):
|
| 126 |
+
logger.info(f"Fetching user profile for {current_user['email']}")
|
| 127 |
+
user = await users_collection.find_one({"email": current_user["email"]})
|
| 128 |
+
if not user:
|
| 129 |
+
logger.warning(f"User not found: {current_user['email']}")
|
| 130 |
+
raise HTTPException(
|
| 131 |
+
status_code=status.HTTP_404_NOT_FOUND,
|
| 132 |
+
detail="User not found"
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
response = {
|
| 136 |
+
"id": str(user["_id"]),
|
| 137 |
+
"email": user["email"],
|
| 138 |
+
"full_name": user.get("full_name", ""),
|
| 139 |
+
"role": user.get("role", "patient"),
|
| 140 |
+
"specialty": user.get("specialty"),
|
| 141 |
+
"created_at": user.get("created_at"),
|
| 142 |
+
"updated_at": user.get("updated_at")
|
| 143 |
}
|
| 144 |
+
logger.info(f"User profile retrieved for {current_user['email']}")
|
| 145 |
+
return response
|
| 146 |
|
| 147 |
# Export the router as 'auth' for api.__init__.py
|
| 148 |
auth = router
|