validators
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user