Add check for non-existing user in auth service
This commit is contained in:
parent
061b7de969
commit
07dcd3d1a7
1 changed files with 3 additions and 0 deletions
|
|
@ -17,6 +17,9 @@ JWT_ISSUER = "Energia"
|
||||||
def authenticate(credentials: Credentials, db: Session) -> Optional[str]:
|
def authenticate(credentials: Credentials, db: Session) -> Optional[str]:
|
||||||
user = get_user_by_username(db, credentials.username)
|
user = get_user_by_username(db, credentials.username)
|
||||||
|
|
||||||
|
if user is None:
|
||||||
|
return None
|
||||||
|
|
||||||
if passwords_match(user.password, credentials.password):
|
if passwords_match(user.password, credentials.password):
|
||||||
token = issue_token(user.id)
|
token = issue_token(user.id)
|
||||||
return token
|
return token
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue