Add check for non-existing user in auth service

This commit is contained in:
Andrey Chervyakov 2021-02-25 15:08:21 +06:00
parent 061b7de969
commit 07dcd3d1a7

View file

@ -17,6 +17,9 @@ JWT_ISSUER = "Energia"
def authenticate(credentials: Credentials, db: Session) -> Optional[str]:
user = get_user_by_username(db, credentials.username)
if user is None:
return None
if passwords_match(user.password, credentials.password):
token = issue_token(user.id)
return token