add filter active and phantom for login view

This commit is contained in:
Cayo Puigdefabregas 2021-04-08 21:19:24 +02:00
parent 9a43ab0097
commit 17a744a660
1 changed files with 1 additions and 1 deletions

View File

@ -18,7 +18,7 @@ def login():
user_s = g.resource_def.SCHEMA(only=('email', 'password')) # type: UserS user_s = g.resource_def.SCHEMA(only=('email', 'password')) # type: UserS
# noinspection PyArgumentList # noinspection PyArgumentList
u = request.get_json(schema=user_s) u = request.get_json(schema=user_s)
user = User.query.filter_by(email=u['email']).one_or_none() user = User.query.filter_by(email=u['email'], active=True, phantom=False).one_or_none()
if user and user.password == u['password']: if user and user.password == u['password']:
schema_with_token = g.resource_def.SCHEMA(exclude=set()) schema_with_token = g.resource_def.SCHEMA(exclude=set())
return schema_with_token.jsonify(user) return schema_with_token.jsonify(user)