From 89c2b324dc897af372be7be1e732355bab4489a5 Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Mon, 12 Feb 2024 15:58:02 -0500 Subject: [PATCH] aimedb: add last login time update to register endpoints --- core/aimedb.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/aimedb.py b/core/aimedb.py index 3b62ba5..08a1b65 100644 --- a/core/aimedb.py +++ b/core/aimedb.py @@ -192,7 +192,8 @@ class AimedbServlette(): f"access_code {req.access_code} -> user_id {ret.user_id}" ) - await self.data.card.update_card_last_login(req.access_code) + if user_id and user_id > 0: + await self.data.card.update_card_last_login(req.access_code) return ret async def handle_lookup_ex(self, data: bytes, resp_code: int) -> ADBBaseResponse: @@ -222,7 +223,8 @@ class AimedbServlette(): self.logger.debug(f"Generated auth token {auth_key}") ret.auth_key = auth_key_full - await self.data.card.update_card_last_login(req.access_code) + if user_id and user_id > 0: + await self.data.card.update_card_last_login(req.access_code) return ret async def handle_felica_lookup(self, data: bytes, resp_code: int) -> bytes: @@ -271,6 +273,8 @@ class AimedbServlette(): f"Registration blocked!: access code {ac} (IDm: {req.idm} PMm: {req.pmm})" ) + if user_id > 0: + await self.data.card.update_card_last_login(ac) return ADBFelicaLookupResponse.from_req(req.head, ac) async def handle_felica_lookup_ex(self, data: bytes, resp_code: int) -> bytes: @@ -295,8 +299,8 @@ class AimedbServlette(): self.logger.debug(f"Generated auth token {auth_key}") resp.auth_key = auth_key_full - - await self.data.card.update_card_last_login(access_code) + if user_id and user_id > 0: + await self.data.card.update_card_last_login(access_code) return resp async def handle_campaign_clear(self, data: bytes, resp_code: int) -> ADBBaseResponse: @@ -338,6 +342,9 @@ class AimedbServlette(): if resp.user_id <= 0: resp.head.status = ADBStatus.BAN_SYS # Closest we can get to a "You cannot register" + else: + await self.data.card.update_card_last_login(req.access_code) + return resp # TODO: Save these in some capacity, as deemed relevant