signIn via email

This commit is contained in:
knst-kotov
2021-08-25 20:12:01 +03:00
parent b36678a4ca
commit 6bdf994a28
4 changed files with 10 additions and 4 deletions

View File

@@ -41,12 +41,16 @@ async def register(*_, email: str, password: str = ""):
@query.field("signIn")
async def login(_, info: GraphQLResolveInfo, email: str, password: str):
async def login(_, info: GraphQLResolveInfo, email: str, password: str = ""):
with local_session() as session:
orm_user = session.query(User).filter(User.email == email).first()
if orm_user is None:
return {"error" : "invalid email"}
if not password:
await send_auth_email(orm_user)
return {"error" : ""}
try:
device = info.context["request"].headers['device']
except KeyError: