authlogs2
All checks were successful
Deploy on push / deploy (push) Successful in 26s

This commit is contained in:
Untone 2024-02-27 14:06:00 +03:00
parent def6921215
commit fc0e3b5541

View File

@ -85,14 +85,14 @@ def login_required(f):
info = args[1]
context = info.context
req = context.get('request')
[user_id, user_roles] = (await check_auth(req)) or []
authorized = await check_auth(req)
if authorized:
user_id, user_roles = authorized
if user_id and user_roles:
logger.info(f' got {user_id} roles: {user_roles}')
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
@ -101,8 +101,11 @@ def auth_request(f):
@wraps(f)
async def decorated_function(*args, **kwargs):
req = args[0]
[user_id, user_roles] = (await check_auth(req)) or []
if user_id:
authorized = await check_auth(req)
if authorized:
user_id, user_roles = authorized
if user_id and user_roles:
logger.info(f' got {user_id} roles: {user_roles}')
req['user_id'] = user_id.strip()
req['roles'] = user_roles
return await f(*args, **kwargs)