refactor: simplify verify_password except clause; drop unused import
This commit is contained in:
@@ -4,7 +4,6 @@ Kept separate from portal_auth (cookie signing) so the future operator auth can
|
|||||||
reuse the same hasher. Never store or log raw passwords."""
|
reuse the same hasher. Never store or log raw passwords."""
|
||||||
import secrets
|
import secrets
|
||||||
from argon2 import PasswordHasher
|
from argon2 import PasswordHasher
|
||||||
from argon2.exceptions import VerifyMismatchError, VerificationError, InvalidHashError
|
|
||||||
|
|
||||||
_ph = PasswordHasher()
|
_ph = PasswordHasher()
|
||||||
|
|
||||||
@@ -18,7 +17,7 @@ def verify_password(raw: str, hashed: str) -> bool:
|
|||||||
"""True iff raw matches the stored hash. Never raises."""
|
"""True iff raw matches the stored hash. Never raises."""
|
||||||
try:
|
try:
|
||||||
return _ph.verify(hashed, raw)
|
return _ph.verify(hashed, raw)
|
||||||
except (VerifyMismatchError, VerificationError, InvalidHashError, Exception):
|
except Exception: # argon2 raises on mismatch/garbage; treat all as "no match"
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import pytest
|
|
||||||
from backend.auth_passwords import hash_password, verify_password, generate_password
|
from backend.auth_passwords import hash_password, verify_password, generate_password
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user