less-logs
All checks were successful
deploy / deploy (push) Successful in 1m17s

This commit is contained in:
Untone 2023-12-19 17:39:53 +03:00
parent afe96fc909
commit 85a40eba83

View File

@ -10,7 +10,7 @@ async def check_auth(req) -> str | None:
user_id = "" user_id = ""
if token: if token:
# Logging the authentication token # Logging the authentication token
print(f"[services.auth] checking auth token: {token}") # print(f"[services.auth] checking auth token: {token}")
query_name = "validate_jwt_token" query_name = "validate_jwt_token"
operation = "ValidateToken" operation = "ValidateToken"
headers = { headers = {
@ -40,6 +40,7 @@ async def check_auth(req) -> str | None:
print(f"[services.auth] errors: {errors}") print(f"[services.auth] errors: {errors}")
else: else:
user_id = data.get("data", {}).get(query_name, {}).get("claims", {}).get("sub") user_id = data.get("data", {}).get(query_name, {}).get("claims", {}).get("sub")
print(f"[services.auth] got user_id: {user_id}")
return user_id return user_id
except Exception as e: except Exception as e:
# Handling and logging exceptions during authentication check # Handling and logging exceptions during authentication check
@ -54,9 +55,7 @@ def login_required(f):
async def decorated_function(*args, **kwargs): async def decorated_function(*args, **kwargs):
info = args[1] info = args[1]
context = info.context context = info.context
print("[login_required] context: " + str(context))
req = context.get("request") req = context.get("request")
print("[login_required] request: " + str(req))
user_id = await check_auth(req) user_id = await check_auth(req)
if user_id: if user_id:
context["user_id"] = user_id context["user_id"] = user_id