error-handle-create-shout-2
All checks were successful
Deploy on push / deploy (push) Successful in 25s

This commit is contained in:
Untone 2024-02-26 12:52:22 +03:00
parent 4a57866c3d
commit ced8c9f75c

View File

@ -1,6 +1,6 @@
from functools import wraps
import httpx
from starlette.exceptions import HTTPException
from settings import ADMIN_SECRET, AUTH_URL
from services.logger import root_logger as logger
@ -45,6 +45,7 @@ async def check_auth(req):
}
data = await request_data(gql)
if data:
logger.debug(data)
user_data = data.get('data', {}).get(query_name, {}).get('claims', {})
user_id = user_data.get('sub')
user_roles = user_data.get('allowed_roles')
@ -83,6 +84,8 @@ def login_required(f):
context['user_id'] = user_id.strip()
context['roles'] = user_roles
return await f(*args, **kwargs)
else:
raise HTTPException(status_code=401, detail='Unauthorized')
return decorated_function
@ -96,5 +99,7 @@ def auth_request(f):
req['user_id'] = user_id.strip()
req['roles'] = user_roles
return await f(*args, **kwargs)
else:
raise HTTPException(status_code=401, detail='Unauthorized')
return decorated_function