Misc auth fixes
authorJohn Hodge <[email protected]>
Mon, 27 Feb 2017 12:20:42 +0000 (20:20 +0800)
committerJohn Hodge <[email protected]>
Mon, 27 Feb 2017 12:20:42 +0000 (20:20 +0800)
VendServer/OpenDispense.py
VendServer/VendServer.py

index 0ce8223..a802e78 100644 (file)
@@ -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():
index f7bc992..aee2305 100755 (executable)
@@ -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 = ''

UCC git Repository :: git.ucc.asn.au