fix(auth): Update API response parsing to handle nested structure
- Fix 'id_user' key not found error by navigating the correct nested path - Extract id_user from data.user.applications[0].users[0].id_user - Add fallback to old structure for backward compatibility - Prevents authentication failures due to API response format changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,12 @@ class AuthHandler:
|
||||
|
||||
try:
|
||||
login_data: Dict[str, Any] = response.json()
|
||||
# Try to find id_user in the nested structure
|
||||
try:
|
||||
# First try the new structure: data.user.applications[0].users[0].id_user
|
||||
self.user_id = str(login_data["data"]["user"]["applications"][0]["users"][0]["id_user"])
|
||||
except (KeyError, IndexError, TypeError):
|
||||
# Fallback to old structure if it exists
|
||||
self.user_id = str(login_data["data"]["user"]["id_user"])
|
||||
except (KeyError, ValueError) as e:
|
||||
logging.error(f"Error during login: {str(e)} - Response: {response.text}")
|
||||
|
||||
Reference in New Issue
Block a user