mirror of
https://github.com/lnbits/lnbits.git
synced 2025-04-21 22:14:57 +02:00
add better error handling
This commit is contained in:
parent
b80f2f8e4d
commit
302ccfd429
@ -55,6 +55,26 @@ async def api_card_create_or_update(
|
||||
card_id: str = None,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
):
|
||||
if(len(bytes.fromhex(data.uid)) != 7):
|
||||
raise HTTPException(
|
||||
detail="Invalid bytes for card uid.", status_code=HTTPStatus.BAD_REQUEST
|
||||
)
|
||||
|
||||
if(len(bytes.fromhex(data.k0)) != 16):
|
||||
raise HTTPException(
|
||||
detail="Invalid bytes for k0.", status_code=HTTPStatus.BAD_REQUEST
|
||||
)
|
||||
|
||||
if(len(bytes.fromhex(data.k1)) != 16):
|
||||
raise HTTPException(
|
||||
detail="Invalid bytes for k1.", status_code=HTTPStatus.BAD_REQUEST
|
||||
)
|
||||
|
||||
if(len(bytes.fromhex(data.k2)) != 16):
|
||||
raise HTTPException(
|
||||
detail="Invalid bytes for k2.", status_code=HTTPStatus.BAD_REQUEST
|
||||
)
|
||||
|
||||
if card_id:
|
||||
card = await get_card(card_id)
|
||||
if not card:
|
||||
|
Loading…
x
Reference in New Issue
Block a user