Ali2206 commited on
Commit
7eb0e9b
·
verified ·
1 Parent(s): af77abb

Update api/routes/auth.py

Browse files
Files changed (1) hide show
  1. api/routes/auth.py +9 -19
api/routes/auth.py CHANGED
@@ -123,26 +123,16 @@ 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
- 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
 
123
 
124
  @router.get("/me")
125
  async def get_me(current_user: dict = Depends(get_current_user)):
126
+ logger.info(f"Returning cached user: {current_user['email']}")
127
+ return {
128
+ "id": str(current_user.get('_id', '')),
129
+ "email": current_user["email"],
130
+ "full_name": current_user.get("full_name", ""),
131
+ "role": current_user.get("role", "patient"),
132
+ "specialty": current_user.get("specialty"),
133
+ "created_at": current_user.get("created_at"),
134
+ "updated_at": current_user.get("updated_at")
 
 
 
 
 
 
 
 
135
  }
 
 
136
 
137
  # Export the router as 'auth' for api.__init__.py
138
  auth = router