inspected
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import json
|
||||
from functools import wraps
|
||||
|
||||
from httpx import AsyncClient, HTTPError
|
||||
@@ -19,19 +18,13 @@ async def check_auth(req):
|
||||
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,
|
||||
}
|
||||
|
||||
async with AsyncClient() as client:
|
||||
response = await client.post(AUTH_URL, headers=headers, data=json.dumps(gql))
|
||||
response = await client.post(AUTH_URL, headers=headers, json=gql)
|
||||
print(f"[services.auth] response: {response.status_code} {response.text}")
|
||||
if response.status_code != 200:
|
||||
return False, None
|
||||
@@ -40,10 +33,7 @@ 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
|
||||
|
Reference in New Issue
Block a user