diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-29 03:01:08 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-29 03:01:08 +0100 |
commit | 8a8f16bdf554d6fc3cd448cdf3bda41f2ee7d6ac (patch) | |
tree | 93b7abff1ba703d702242feb65753e9f5c29b3b2 /mu4web | |
parent | Properly specify version requirements, and add directory layout. (diff) | |
download | mu4web-8a8f16bdf554d6fc3cd448cdf3bda41f2ee7d6ac.tar.gz mu4web-8a8f16bdf554d6fc3cd448cdf3bda41f2ee7d6ac.tar.xz |
Fix crash on invalid username.
Diffstat (limited to 'mu4web')
-rwxr-xr-x | mu4web/password.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mu4web/password.py b/mu4web/password.py index ff0df21..2b4aaa0 100755 --- a/mu4web/password.py +++ b/mu4web/password.py @@ -82,7 +82,9 @@ class Passwords: def validate(self, username: str, password: str) -> bool: """Check if user exists, and if it has a correct password.""" # These shall fail when key is missing - data = self.db[username] + data = self.db.get(username) + if not data: + return False proc = hash_methods[data['method']] digest = proc((data['salt'] + password).encode('UTF-8')).hexdigest() return data['hash'] == digest |