From: John Hodge Date: Mon, 20 Feb 2017 11:14:37 +0000 (+0800) Subject: Fix MIFARE card enrollment and login X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=6838aa5069d4078fef452e626076dde15c596c03;p=uccvend-vendserver.git Fix MIFARE card enrollment and login --- diff --git a/VendServer/OpenDispense.py b/VendServer/OpenDispense.py index c8dcf83..0ce8223 100644 --- a/VendServer/OpenDispense.py +++ b/VendServer/OpenDispense.py @@ -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 diff --git a/VendServer/VendServer.py b/VendServer/VendServer.py index 3ac2b81..6c52933 100755 --- a/VendServer/VendServer.py +++ b/VendServer/VendServer.py @@ -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)