This commit is contained in:
parent
38c0a4e3ee
commit
63cf0b9fee
|
@ -60,9 +60,7 @@ def login_required(f):
|
|||
info = args[1]
|
||||
context = info.context
|
||||
req = context.get("request")
|
||||
authorized = await check_auth(req)
|
||||
if authorized:
|
||||
user_id, user_roles = authorized
|
||||
user_id, user_roles = await check_auth(req)
|
||||
if user_id and isinstance(user_id, str):
|
||||
context["user_id"] = user_id.strip()
|
||||
author = get_author_by_user(user_id)
|
||||
|
@ -79,16 +77,12 @@ def auth_request(f):
|
|||
@wraps(f)
|
||||
async def decorated_function(*args, **kwargs):
|
||||
req = args[0]
|
||||
authorized = await check_auth(req)
|
||||
if authorized:
|
||||
user_id, user_roles = authorized
|
||||
user_id, user_roles = await check_auth(req)
|
||||
if user_id and isinstance(user_id, str):
|
||||
user_id = user_id.strip()
|
||||
author = get_author_by_user(user_id)
|
||||
if author and "id" in author:
|
||||
req["author_id"] = author["id"]
|
||||
else:
|
||||
logger.error('cannot find author')
|
||||
return await f(*args, **kwargs)
|
||||
else:
|
||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||
|
|
Loading…
Reference in New Issue
Block a user