Fix MIFARE card enrollment and login
authorJohn Hodge <[email protected]>
Mon, 20 Feb 2017 11:14:37 +0000 (19:14 +0800)
committerJohn Hodge <[email protected]>
Mon, 20 Feb 2017 11:14:37 +0000 (19:14 +0800)
VendServer/OpenDispense.py
VendServer/VendServer.py

index c8dcf83..0ce8223 100644 (file)
@@ -72,6 +72,8 @@ class OpenDispense(DispenseInterface):
                return False
 
        def authMifareCard(self, cardId):
+               self._loggedIn = False
+               self._username = None
                if DISPSRV_MIFARE:
                        card_base64 = base64.b64encode(cardId)
                        
@@ -86,7 +88,7 @@ class OpenDispense(DispenseInterface):
                        sockf.write("AUTHCARD %s\n" % (card_base64,)); sockf.flush()
                        rsp = sockf.readline()
                        if not "200" in rsp:
-                               raise ValueError, "no UID found for card ID"
+                               return False
                        username = rsp.split('=')[1].strip()
 
                        # Check for thier username
@@ -127,10 +129,10 @@ class OpenDispense(DispenseInterface):
                        sockf.write("AUTHIDENT\n")
                        sockf.flush(); rsp = sockf.readline()
                        assert "200" in rsp
-                       sockf.write("SETEUSER %s\n", self._username)
+                       sockf.write("SETEUSER %s\n" % (self._username,))
                        sockf.flush(); rsp = sockf.readline()
                        assert "200" in rsp
-                       sockf.write("CARD_ADD %s\n", card_base64)
+                       sockf.write("CARD_ADD %s\n" % (card_base64,))
                        sockf.flush(); rsp = sockf.readline()
                        if "200" in rsp:
                                return True
index 3ac2b81..6c52933 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/python
-# vim:ts=4
+# vim: ts=4 sts=4 sw=4 noexpandtab
 
 USE_MIFARE = 1
 
@@ -481,6 +481,7 @@ class VendServer():
                        if len(self.vstatus.cur_pin) == PIN_LENGTH:
                                self.dispense.authUserIdPin(self.vstatus.cur_user, self.vstatus.cur_pin)
                                if self.dispense.getUsername():
+                                       self.vstatus.username = self.dispense.getUsername()
                                        self.v.beep(0, False)
                                        self.vstatus.cur_selection = ''
                                        self.vstatus.change_state(STATE_GET_SELECTION)

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