error handling if bad input data in db
This commit is contained in:
@@ -117,11 +117,14 @@ async def api_scane(p, c, request: Request):
|
|||||||
# so I try one by one until decrypted uid matches
|
# so I try one by one until decrypted uid matches
|
||||||
for cand in await get_all_cards():
|
for cand in await get_all_cards():
|
||||||
if cand.k1:
|
if cand.k1:
|
||||||
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1))
|
try:
|
||||||
|
card_uid, counter = decryptSUN(bytes.fromhex(p), bytes.fromhex(cand.k1))
|
||||||
|
|
||||||
if card_uid.hex().upper() == cand.uid:
|
if card_uid.hex().upper() == cand.uid:
|
||||||
card = cand
|
card = cand
|
||||||
break
|
break
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
if card == None:
|
if card == None:
|
||||||
return {"status": "ERROR", "reason": "Unknown card."}
|
return {"status": "ERROR", "reason": "Unknown card."}
|
||||||
|
|||||||
Reference in New Issue
Block a user