Commit 1290fcdd authored by John Hodge's avatar John Hodge
Browse files

Misc auth fixes

parent 50ed02d2
......@@ -116,6 +116,11 @@ class OpenDispense(DispenseInterface):
self._userid = info.pw_uid
self._username = info.pw_name
return True
def logOut(self):
self._loggedIn = False
self._disabled = False
self._userId = None
self._username = None
def addCard(self, cardId):
if not self.isLoggedIn():
......
......@@ -385,7 +385,7 @@ class VendServer():
return
else:
self.vstatus.cur_selection += chr(key + ord('0'))
if self.vstatus.cur_user:
if self.dispense.isLoggedIn():
self.make_selection()
self.vstatus.cur_selection = ''
self.vstatus.time_to_autologout = time() + 8
......@@ -480,8 +480,7 @@ class VendServer():
self.vstatus.cur_pin += chr(key + ord('0'))
self.vstatus.mk.set_message('PIN: '+'X'*len(self.vstatus.cur_pin))
if len(self.vstatus.cur_pin) == PIN_LENGTH:
self.dispense.authUserIdPin(self.vstatus.cur_user, self.vstatus.cur_pin)
if self.dispense.getUsername():
if self.dispense.authUserIdPin(self.vstatus.cur_user, self.vstatus.cur_pin):
self.vstatus.username = self.dispense.getUsername()
self.v.beep(0, False)
self.vstatus.cur_selection = ''
......@@ -598,6 +597,7 @@ class VendServer():
key = params
if key == 11:
self.vstatus.cur_user = ''
self.dispense.logOut()
self.reset_idler()
return
......@@ -762,6 +762,7 @@ class VendServer():
logging.warning("Entering open door mode")
self.v.display("-FEED ME-")
#door_open_mode(v);
self.dispense.logOut()
self.vstatus.cur_user = ''
self.vstatus.cur_pin = ''
elif params == 1: #door closed
......@@ -782,9 +783,7 @@ class VendServer():
self._last_card_id = card_id
self.dispense.authMifareCard(card_id)
logging.info('Mapped card id to uid %s'%self.dispense.getUsername())
if not self.dispense.isLoggedIn():
if not self.dispense.authMifareCard(card_id):
self.v.beep(40, False)
self.vstatus.mk.set_messages(
[(self.center('BAD CARD'), False, 1.0),
......@@ -796,6 +795,7 @@ class VendServer():
self.reset_idler(2)
return
elif self.dispense.isDisabled():
logging.info('Mapped card id to uid %s'%self.dispense.getUsername())
self.v.beep(40, False)
self.vstatus.mk.set_messages(
[(self.center('ACCT DISABLED'), False, 1.0),
......@@ -804,6 +804,7 @@ class VendServer():
self.reset_idler(2)
return
else:
logging.info('Mapped card id to uid %s'%self.dispense.getUsername())
self.vstatus.cur_user = '----'
self.vstatus.username = self.dispense.getUsername()
self.vstatus.cur_selection = ''
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment