From 07dcd3d1a7abbf26104cdc553065c4bcf15c4a02 Mon Sep 17 00:00:00 2001 From: Andrey Chervyakov Date: Thu, 25 Feb 2021 15:08:21 +0600 Subject: [PATCH] Add check for non-existing user in auth service --- app/auth/service.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/auth/service.py b/app/auth/service.py index f47d5df..f1ab419 100644 --- a/app/auth/service.py +++ b/app/auth/service.py @@ -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