Checking onboardin flow - fix 4
This commit is contained in:
@@ -182,9 +182,11 @@ class AuthMiddleware(BaseHTTPMiddleware):
|
||||
return False
|
||||
|
||||
# Validate token type
|
||||
if payload.get("type") != "access":
|
||||
token_type = payload.get("type")
|
||||
if token_type not in ["access", "service"]:
|
||||
logger.warning(f"Invalid token type: {payload.get('type')}")
|
||||
return False
|
||||
|
||||
|
||||
return True
|
||||
|
||||
@@ -193,12 +195,19 @@ class AuthMiddleware(BaseHTTPMiddleware):
|
||||
Convert JWT payload to user context format
|
||||
FIXED: Proper mapping between JWT structure and user context
|
||||
"""
|
||||
return {
|
||||
base_context = {
|
||||
"user_id": payload["user_id"],
|
||||
"email": payload["email"],
|
||||
"exp": payload["exp"],
|
||||
"valid": True
|
||||
}
|
||||
|
||||
if payload.get("service"):
|
||||
base_context["service"] = payload["service"]
|
||||
base_context["type"] = "service"
|
||||
logger.debug(f"Service authentication: {payload['service']}")
|
||||
|
||||
return base_context
|
||||
|
||||
async def _verify_with_auth_service(self, token: str) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user