diff --git a/server/auth/utils.py b/server/auth/utils.py index 0c1a5cb..55057b6 100644 --- a/server/auth/utils.py +++ b/server/auth/utils.py @@ -2,12 +2,16 @@ from fastapi.security import OAuth2PasswordBearer from argon2 import PasswordHasher +from argon2.exceptions import VerificationError oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/api/auth/token", auto_error=False) _ph = PasswordHasher() def verify_password(password: str, password_hash: str) -> bool: - return _ph.verify(password_hash, password) + try: + return _ph.verify(password_hash, password) + except VerificationError: + return False def hash_password(password: str) -> str: password_hash = _ph.hash(password)