format
This commit is contained in:
parent
4242a82029
commit
9dd7d30716
2 changed files with 6 additions and 2 deletions
|
|
@ -82,6 +82,7 @@ async def get_card(card_id: str) -> Optional[Card]:
|
|||
|
||||
return Card.parse_obj(card)
|
||||
|
||||
|
||||
async def get_card_by_uid(card_uid: str) -> Optional[Card]:
|
||||
row = await db.fetchone("SELECT * FROM boltcards.cards WHERE uid = ?", (card_uid,))
|
||||
if not row:
|
||||
|
|
@ -91,6 +92,7 @@ async def get_card_by_uid(card_uid: str) -> Optional[Card]:
|
|||
|
||||
return Card.parse_obj(card)
|
||||
|
||||
|
||||
async def get_card_by_otp(otp: str) -> Optional[Card]:
|
||||
row = await db.fetchone("SELECT * FROM boltcards.cards WHERE otp = ?", (otp,))
|
||||
if not row:
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ async def api_hits(
|
|||
# /boltcards/api/v1/scan?p=00000000000000000000000000000000&c=0000000000000000
|
||||
@boltcards_ext.get("/api/v1/scan")
|
||||
@boltcards_ext.get("/api/v1/scan/{card_uid}")
|
||||
async def api_scane(p, c, card_uid: str = None, request: Request):
|
||||
async def api_scane(p, c, request: Request, card_uid: str = None):
|
||||
# some wallets send everything as lower case, no bueno
|
||||
p = p.upper()
|
||||
c = c.upper()
|
||||
|
|
@ -146,7 +146,9 @@ async def api_scane(p, c, card_uid: str = None, request: Request):
|
|||
for cand in await get_all_cards():
|
||||
if cand.k1:
|
||||
try:
|
||||
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1))
|
||||
card_uid, counter = decryptSUN(
|
||||
bytes.fromhex(p), bytes.fromhex(cand.k1)
|
||||
)
|
||||
|
||||
if card_uid.hex().upper() == cand.uid.upper():
|
||||
card = cand
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue