Skip to content

Commit

Permalink
fix: postgres auth
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisVLRT committed Jan 17, 2024
1 parent fb37721 commit 75b0ef0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/user_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class UnsecureUser(BaseModel):

class User(BaseModel):
email: str = None
hashed_password: bytes = None
hashed_password: str = None

@classmethod
def from_unsecure_user(cls, unsecure_user: UnsecureUser):
hashed_password = argon2.hash_password(unsecure_user.password)
hashed_password = argon2.hash_password(unsecure_user.password).decode("utf-8")
return cls(email=unsecure_user.email, hashed_password=hashed_password)


Expand Down Expand Up @@ -57,7 +57,7 @@ def authenticate_user(username: str, password: bytes) -> bool | User:
if not user:
return False

if argon2.verify_password(user.hashed_password, password.encode("utf-8")):
if argon2.verify_password(user.hashed_password.encode("utf-8"), password.encode("utf-8")):
return user

return False
Expand Down

0 comments on commit 75b0ef0

Please sign in to comment.