Commit 6838aa50 authored by John Hodge's avatar John Hodge
Browse files

Fix MIFARE card enrollment and login

parent 2a07cd68
......@@ -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
......
#!/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)
......
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