From e6a5b248838f455bda2a609a5301d29808f9b969 Mon Sep 17 00:00:00 2001 From: Jaculabilis Date: Sat, 27 Jan 2018 17:58:11 -0600 Subject: [PATCH] Fixed authorization check --- validate.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/validate.py b/validate.py index b2741c1..04b6b68 100644 --- a/validate.py +++ b/validate.py @@ -39,7 +39,7 @@ def unlock_door(p): """ try: p.start(DUTYCYCLE) - xtime.sleep(DURATION) + time.sleep(DURATION) finally: p.stop() @@ -69,8 +69,12 @@ def read_loop(): # Read in the ID code = socket.recv() # Determine ID authorization - authorized = code in access and "authorized" in access[code] and access[code]["authorized"] - user = access[code]["user"] if code in access and "user" in access[code] else "unknown barcode" + if code not in access: + authorized = False + user = "unknown barcode" + else: + authorized = "authorized" in access[code] and access[code]["authorized"] + user = access[code]["user"] if "user" in access[code] else code # If the user is not authorized, deny access if not authorized: s = timestamped("Denied {} ({})\n".format(code, user))