aboutsummaryrefslogtreecommitdiff
path: root/mu4web
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-11-29 03:01:08 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-11-29 03:01:08 +0100
commit8a8f16bdf554d6fc3cd448cdf3bda41f2ee7d6ac (patch)
tree93b7abff1ba703d702242feb65753e9f5c29b3b2 /mu4web
parentProperly specify version requirements, and add directory layout. (diff)
downloadmu4web-8a8f16bdf554d6fc3cd448cdf3bda41f2ee7d6ac.tar.gz
mu4web-8a8f16bdf554d6fc3cd448cdf3bda41f2ee7d6ac.tar.xz
Fix crash on invalid username.
Diffstat (limited to 'mu4web')
-rwxr-xr-xmu4web/password.py4
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