Revert previous commit
This commit is contained in:
parent
84d262b838
commit
061b7de969
1 changed files with 3 additions and 7 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue