validators

This commit is contained in:
2023-10-14 09:38:12 +03:00
parent ee195d4ec7
commit d6e52d9465
9 changed files with 116 additions and 95 deletions

View File

@@ -15,15 +15,18 @@ async def check_auth(req):
query_type = "mutation" if INTERNAL_AUTH_SERVER else "query"
operation = "GetUserId"
headers = {
"Authorization": 'Bearer ' + token,
"Content-Type": "application/json"
}
headers = {"Authorization": "Bearer " + token, "Content-Type": "application/json"}
gql = {
"query": query_type + " " + operation + " { " + query_name + " { user { id } } " + " }",
"query": query_type
+ " "
+ operation
+ " { "
+ query_name
+ " { user { id } } "
+ " }",
"operationName": operation,
"variables": None
"variables": None,
}
async with AsyncClient() as client:
@@ -36,7 +39,10 @@ async def check_auth(req):
user_id = (
r.get("data", {}).get(query_name, {}).get("user", {}).get("id", None)
if INTERNAL_AUTH_SERVER
else r.get("data", {}).get(query_name, {}).get("user", {}).get("id", None)
else r.get("data", {})
.get(query_name, {})
.get("user", {})
.get("id", None)
)
is_authenticated = user_id is not None
return is_authenticated, user_id