This commit is contained in:
parent
517de93ccd
commit
bc8a07e619
|
@ -13,7 +13,7 @@ async def check_auth(req) -> (bool, int | None):
|
|||
# Logging the authentication token
|
||||
print(f"[services.auth] checking auth token: {token}")
|
||||
query_name = "validate_jwt_token"
|
||||
operation = "ValidateToken"
|
||||
opeation = "ValidateToken"
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
@ -26,18 +26,18 @@ async def check_auth(req) -> (bool, int | None):
|
|||
}
|
||||
|
||||
gql = {
|
||||
"query": f"query {operation}($params: ValidateJWTTokenInput!) {{ {query_name}(params: $params) {{ is_valid claims }} }}",
|
||||
"query": f"query {opeation}($params: ValidateJWTTokenInput!) {{ {query_name}(params: $params) {{ is_valid claims }} }}",
|
||||
"variables": variables,
|
||||
"operationName": operation,
|
||||
"operationName": opeation,
|
||||
}
|
||||
print(f"[services.auth] Graphql: {gql}")
|
||||
# print(f"[services.auth] Graphql: {gql}")
|
||||
try:
|
||||
# Asynchronous HTTP request to the authentication server
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(AUTH_URL, json=gql, headers=headers) as response:
|
||||
# Logging the GraphQL response
|
||||
response_text = await response.text()
|
||||
print(f"[services.auth] GraphQL Response: {response_text}")
|
||||
# response_text = await response.text()
|
||||
# print(f"[services.auth] GraphQL Response: {response_text}")
|
||||
|
||||
if response.status == 200:
|
||||
# Parsing JSON response
|
||||
|
@ -50,14 +50,16 @@ async def check_auth(req) -> (bool, int | None):
|
|||
|
||||
if user_id:
|
||||
# Logging the retrieved user ID
|
||||
print(f"[services.auth] User ID retrieved: {user_id}")
|
||||
# print(f"[services.auth] User ID retrieved: {user_id}")
|
||||
return True, user_id
|
||||
else:
|
||||
# Logging when no user ID is found in the response
|
||||
print("[services.auth] No user ID found in the response")
|
||||
# print("[services.auth] No user ID found in the response")
|
||||
pass
|
||||
else:
|
||||
# Logging when the request to the authentication server fails
|
||||
print(f"[services.auth] Request failed with status: {response.status}")
|
||||
# print(f"[services.auth] Request failed with status: {response.status}")
|
||||
pass
|
||||
|
||||
except Exception as e:
|
||||
# Handling and logging exceptions during authentication check
|
||||
|
|
Loading…
Reference in New Issue
Block a user