Commit e35a527c authored by Your Name's avatar Your Name

Add debug logging to token authentication

Shows authenticated_username vs requested_username in error response
to help diagnose username mismatch issues
parent 5f7660b3
......@@ -1349,10 +1349,17 @@ async def api_token_authorization_middleware(request: Request, call_next):
content={"error": "Invalid user token."}
)
# Debug logging
logger.info(f"Token auth check: user_id={user_id}, authenticated_username={authenticated_user.get('username')}, target_username={target_username}")
if authenticated_user['username'] != target_username:
return JSONResponse(
status_code=403,
content={"error": "You can only access your own user-specific endpoints."}
content={
"error": "You can only access your own user-specific endpoints.",
"authenticated_as": authenticated_user['username'],
"requested_user": target_username
}
)
# --- GLOBAL ENDPOINTS (all other API paths) ---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment