From 1290fcdd454618a5b61f27d81d3312d95d933206 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 27 Feb 2017 20:20:42 +0800 Subject: [PATCH] Misc auth fixes --- VendServer/OpenDispense.py | 5 +++++ VendServer/VendServer.py | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/VendServer/OpenDispense.py b/VendServer/OpenDispense.py index 0ce8223..a802e78 100644 --- a/VendServer/OpenDispense.py +++ b/VendServer/OpenDispense.py @@ -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(): diff --git a/VendServer/VendServer.py b/VendServer/VendServer.py index f7bc992..aee2305 100755 --- a/VendServer/VendServer.py +++ b/VendServer/VendServer.py @@ -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 = '' -- 2.20.1