From 061b7de9697b7984fd97128f5406e5b4d9c6422b Mon Sep 17 00:00:00 2001 From: Andrey Chervyakov Date: Thu, 25 Feb 2021 15:05:28 +0600 Subject: [PATCH] Revert previous commit --- app/auth/service.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/auth/service.py b/app/auth/service.py index 68f8419..f47d5df 100644 --- a/app/auth/service.py +++ b/app/auth/service.py @@ -5,7 +5,6 @@ from typing import Optional from jose import jwt from jose.constants import ALGORITHMS from sqlalchemy.orm import Session -import secrets from app.auth.dto import Credentials from app.config import config @@ -18,14 +17,11 @@ JWT_ISSUER = "Energia" def authenticate(credentials: Credentials, db: Session) -> Optional[str]: user = get_user_by_username(db, credentials.username) - if not secrets.compare_digest(user.username, credentials.username): - return None - - if not passwords_match(user.password, credentials.password): - return None - else: + if passwords_match(user.password, credentials.password): token = issue_token(user.id) return token + else: + return None def issue_token(user_id: int) -> str: