Fixed authorization check

This commit is contained in:
Jaculabilis 2018-01-27 17:58:11 -06:00
parent 685aaf0bdd
commit e6a5b24883
1 changed files with 7 additions and 3 deletions

View File

@ -39,7 +39,7 @@ def unlock_door(p):
""" """
try: try:
p.start(DUTYCYCLE) p.start(DUTYCYCLE)
xtime.sleep(DURATION) time.sleep(DURATION)
finally: finally:
p.stop() p.stop()
@ -69,8 +69,12 @@ def read_loop():
# Read in the ID # Read in the ID
code = socket.recv() code = socket.recv()
# Determine ID authorization # Determine ID authorization
authorized = code in access and "authorized" in access[code] and access[code]["authorized"] if code not in access:
user = access[code]["user"] if code in access and "user" in access[code] else "unknown barcode" 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 the user is not authorized, deny access
if not authorized: if not authorized:
s = timestamped("Denied {} ({})\n".format(code, user)) s = timestamped("Denied {} ({})\n".format(code, user))