more validation
This commit is contained in:
parent
302ccfd429
commit
6898412e6c
1 changed files with 13 additions and 8 deletions
|
|
@ -55,25 +55,30 @@ async def api_card_create_or_update(
|
||||||
card_id: str = None,
|
card_id: str = None,
|
||||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||||
):
|
):
|
||||||
if(len(bytes.fromhex(data.uid)) != 7):
|
try:
|
||||||
raise HTTPException(
|
if len(bytes.fromhex(data.uid)) != 7:
|
||||||
|
raise HTTPException(
|
||||||
detail="Invalid bytes for card uid.", status_code=HTTPStatus.BAD_REQUEST
|
detail="Invalid bytes for card uid.", status_code=HTTPStatus.BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
if(len(bytes.fromhex(data.k0)) != 16):
|
if len(bytes.fromhex(data.k0)) != 16:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Invalid bytes for k0.", status_code=HTTPStatus.BAD_REQUEST
|
detail="Invalid bytes for k0.", status_code=HTTPStatus.BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
if(len(bytes.fromhex(data.k1)) != 16):
|
if len(bytes.fromhex(data.k1)) != 16:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Invalid bytes for k1.", status_code=HTTPStatus.BAD_REQUEST
|
detail="Invalid bytes for k1.", status_code=HTTPStatus.BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
|
||||||
if(len(bytes.fromhex(data.k2)) != 16):
|
if len(bytes.fromhex(data.k2)) != 16:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Invalid bytes for k2.", status_code=HTTPStatus.BAD_REQUEST
|
detail="Invalid bytes for k2.", status_code=HTTPStatus.BAD_REQUEST
|
||||||
)
|
)
|
||||||
|
except:
|
||||||
|
raise HTTPException(
|
||||||
|
detail="Invalid byte data provided.", status_code=HTTPStatus.BAD_REQUEST
|
||||||
|
)
|
||||||
|
|
||||||
if card_id:
|
if card_id:
|
||||||
card = await get_card(card_id)
|
card = await get_card(card_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue