some more fixes
This commit is contained in:
parent
b2b8cf747f
commit
59640df3bc
|
@ -58,6 +58,7 @@ def login_required(func):
|
|||
async def wrap(parent, info: GraphQLResolveInfo, *args, **kwargs):
|
||||
# print('[auth.authenticate] login required for %r with info %r' % (func, info)) # debug only
|
||||
auth: AuthCredentials = info.context["request"].auth
|
||||
print('[auth.authenticate] request auth data: %r' % auth) # debug only
|
||||
if not auth.logged_in:
|
||||
return {"error": auth.error_message or "Please login"}
|
||||
return await func(parent, info, *args, **kwargs)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import asyncio
|
||||
from sqlalchemy.orm import selectinload
|
||||
from sqlalchemy.orm import selectinload, exc
|
||||
from orm.user import User
|
||||
from base.orm import local_session
|
||||
|
||||
|
@ -22,16 +22,18 @@ class UserStorage:
|
|||
@staticmethod
|
||||
async def get_user(id):
|
||||
with local_session() as session:
|
||||
user = (
|
||||
session.query(User).options(
|
||||
selectinload(User.roles),
|
||||
selectinload(User.ratings)
|
||||
).filter(
|
||||
User.id == id
|
||||
).one()
|
||||
)
|
||||
|
||||
return user
|
||||
try:
|
||||
user = (
|
||||
session.query(User).options(
|
||||
selectinload(User.roles),
|
||||
selectinload(User.ratings)
|
||||
).filter(
|
||||
User.id == id
|
||||
).one()
|
||||
)
|
||||
return user
|
||||
except exc.NoResultFound:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
async def get_all_users():
|
||||
|
|
Loading…
Reference in New Issue
Block a user