forked from Hay1tsme/artemis
aimedb: update card last login time properly
This commit is contained in:
parent
d4e00781c8
commit
4149944d56
@ -191,6 +191,8 @@ class AimedbServlette():
|
|||||||
self.logger.info(
|
self.logger.info(
|
||||||
f"access_code {req.access_code} -> user_id {ret.user_id}"
|
f"access_code {req.access_code} -> user_id {ret.user_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await self.data.card.update_card_last_login(req.access_code)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
async def handle_lookup_ex(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
async def handle_lookup_ex(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||||
@ -220,6 +222,7 @@ class AimedbServlette():
|
|||||||
self.logger.debug(f"Generated auth token {auth_key}")
|
self.logger.debug(f"Generated auth token {auth_key}")
|
||||||
ret.auth_key = auth_key_full
|
ret.auth_key = auth_key_full
|
||||||
|
|
||||||
|
await self.data.card.update_card_last_login(req.access_code)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
async def handle_felica_lookup(self, data: bytes, resp_code: int) -> bytes:
|
async def handle_felica_lookup(self, data: bytes, resp_code: int) -> bytes:
|
||||||
@ -292,6 +295,8 @@ class AimedbServlette():
|
|||||||
self.logger.debug(f"Generated auth token {auth_key}")
|
self.logger.debug(f"Generated auth token {auth_key}")
|
||||||
resp.auth_key = auth_key_full
|
resp.auth_key = auth_key_full
|
||||||
|
|
||||||
|
|
||||||
|
await self.data.card.update_card_last_login(access_code)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
async def handle_campaign_clear(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
async def handle_campaign_clear(self, data: bytes, resp_code: int) -> ADBBaseResponse:
|
||||||
|
@ -74,6 +74,7 @@ class CardData(BaseData):
|
|||||||
if card["is_banned"]:
|
if card["is_banned"]:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def get_card_locked(self, access_code: str) -> Optional[bool]:
|
async def get_card_locked(self, access_code: str) -> Optional[bool]:
|
||||||
"""
|
"""
|
||||||
Given a 20 digit access code as a string, check if the card is locked
|
Given a 20 digit access code as a string, check if the card is locked
|
||||||
@ -112,6 +113,15 @@ class CardData(BaseData):
|
|||||||
return None
|
return None
|
||||||
return result.lastrowid
|
return result.lastrowid
|
||||||
|
|
||||||
|
async def update_card_last_login(self, access_code: str) -> None:
|
||||||
|
sql = aime_card.update(aime_card.c.access_code == access_code).values(
|
||||||
|
last_login_date=func.now()
|
||||||
|
)
|
||||||
|
|
||||||
|
result = await self.execute(sql)
|
||||||
|
if result is None:
|
||||||
|
self.logger.warn(f"Failed to update last login time for {access_code}")
|
||||||
|
|
||||||
def to_access_code(self, luid: str) -> str:
|
def to_access_code(self, luid: str) -> str:
|
||||||
"""
|
"""
|
||||||
Given a felica cards internal 16 hex character luid, convert it to a 0-padded 20 digit access code as a string
|
Given a felica cards internal 16 hex character luid, convert it to a 0-padded 20 digit access code as a string
|
||||||
|
Loading…
Reference in New Issue
Block a user