fix: do not use assert in http call (#61)
This commit is contained in:
parent
bdef451d89
commit
35dc29822f
1 changed files with 6 additions and 6 deletions
12
views_api.py
12
views_api.py
|
|
@ -81,8 +81,8 @@ async def api_link_retrieve(
|
||||||
|
|
||||||
# admins are allowed to read paylinks beloging to regular users
|
# admins are allowed to read paylinks beloging to regular users
|
||||||
user = await get_user(key_info.wallet.user)
|
user = await get_user(key_info.wallet.user)
|
||||||
assert user, "User does not exist"
|
admin_user = user.admin if user else False
|
||||||
if not user.admin and link_wallet and link_wallet.user != key_info.wallet.user:
|
if not admin_user and link_wallet and link_wallet.user != key_info.wallet.user:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Not your pay link.", status_code=HTTPStatus.FORBIDDEN
|
detail="Not your pay link.", status_code=HTTPStatus.FORBIDDEN
|
||||||
)
|
)
|
||||||
|
|
@ -172,8 +172,8 @@ async def api_link_create_or_update(
|
||||||
|
|
||||||
# admins are allowed to create/edit paylinks beloging to regular users
|
# admins are allowed to create/edit paylinks beloging to regular users
|
||||||
user = await get_user(key_info.wallet.user)
|
user = await get_user(key_info.wallet.user)
|
||||||
assert user, "User does not exist"
|
admin_user = user.admin if user else False
|
||||||
if not user.admin and new_wallet.user != key_info.wallet.user:
|
if not admin_user and new_wallet.user != key_info.wallet.user:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Not your pay link.", status_code=HTTPStatus.FORBIDDEN
|
detail="Not your pay link.", status_code=HTTPStatus.FORBIDDEN
|
||||||
)
|
)
|
||||||
|
|
@ -211,8 +211,8 @@ async def api_link_delete(link_id: str, wallet: WalletTypeInfo = Depends(get_key
|
||||||
|
|
||||||
# admins are allowed to delete paylinks beloging to regular users
|
# admins are allowed to delete paylinks beloging to regular users
|
||||||
user = await get_user(wallet.wallet.user)
|
user = await get_user(wallet.wallet.user)
|
||||||
assert user, "User does not exist"
|
admin_user = user.admin if user else False
|
||||||
if not user.admin and link.wallet != wallet.wallet.id:
|
if not admin_user and link.wallet != wallet.wallet.id:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
detail="Not your pay link.", status_code=HTTPStatus.FORBIDDEN
|
detail="Not your pay link.", status_code=HTTPStatus.FORBIDDEN
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue