This commit is contained in:
parent
9f7143d756
commit
3e0f7b0521
3
main.py
3
main.py
|
@ -16,7 +16,6 @@ from services.rediscache import redis
|
|||
from settings import DEV_SERVER_PID_FILE_NAME, MODE, SENTRY_DSN
|
||||
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger('\t[main]\t')
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
@ -54,4 +53,4 @@ async def shutdown():
|
|||
|
||||
|
||||
app = Starlette(debug=True, on_startup=[start_up], on_shutdown=[shutdown])
|
||||
app.mount('/', GraphQL(schema, debug=True))
|
||||
app.mount('/', GraphQL(schema, graphiql=True, debug=True))
|
||||
|
|
|
@ -37,24 +37,15 @@ async def check_auth(req) -> str | None:
|
|||
try:
|
||||
# Asynchronous HTTP request to the authentication server
|
||||
async with ClientSession() as session:
|
||||
async with session.post(
|
||||
AUTH_URL, json=gql, headers=headers
|
||||
) as response:
|
||||
print(
|
||||
f'[services.auth] HTTP Response {response.status} {await response.text()}'
|
||||
)
|
||||
async with session.post(AUTH_URL, json=gql, headers=headers) as response:
|
||||
print(f'[services.auth] HTTP Response {response.status} {await response.text()}')
|
||||
if response.status == 200:
|
||||
data = await response.json()
|
||||
errors = data.get('errors')
|
||||
if errors:
|
||||
print(f'errors: {errors}')
|
||||
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')
|
||||
if user_id:
|
||||
print(f'[services.auth] got user_id: {user_id}')
|
||||
return user_id
|
||||
|
|
Loading…
Reference in New Issue
Block a user