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