Proper exception handling
This commit is contained in:
1 parent
0cf6bae59d
commit
bfe49e40ed
1 file changed
+2
-1
+2
-1
@@ -1,4 +1,5 @@
|
||||
from argon2 import PasswordHasher
|
||||
from argon2.exceptions import InvalidHashError, VerifyMismatchError
|
||||
|
||||
ph = PasswordHasher()
|
||||
|
||||
@@ -8,7 +9,7 @@ def hash_api_key(api_key: str) -> str:
|
||||
def verify_api_key(api_key: str, hashed: str) -> bool:
|
||||
try:
|
||||
return ph.verify(hashed, api_key)
|
||||
except Exception:
|
||||
except (VerifyMismatchError, InvalidHashError):
|
||||
return False
|
||||
|
||||
if __name__=="__main__":
|
||||
|
||||
Reference in new issue
Block a user