Fix/admin extension exception (#984)
* check if wallet exists * check wallet existence in key check * return FORBIDDEN for LNBITS_ADMIN_USERS
This commit is contained in:
parent
a9084a09f7
commit
c5cc65a736
1 changed files with 6 additions and 2 deletions
|
|
@ -153,14 +153,18 @@ async def get_key_type(
|
||||||
LNBITS_ADMIN_USERS and wallet.wallet.user not in LNBITS_ADMIN_USERS
|
LNBITS_ADMIN_USERS and wallet.wallet.user not in LNBITS_ADMIN_USERS
|
||||||
) and (LNBITS_ADMIN_EXTENSIONS and pathname in LNBITS_ADMIN_EXTENSIONS):
|
) and (LNBITS_ADMIN_EXTENSIONS and pathname in LNBITS_ADMIN_EXTENSIONS):
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.UNAUTHORIZED, detail="User not authorized."
|
status_code=HTTPStatus.FORBIDDEN,
|
||||||
|
detail="User not authorized for this extension.",
|
||||||
)
|
)
|
||||||
return wallet
|
return wallet
|
||||||
except HTTPException as e:
|
except HTTPException as e:
|
||||||
if e.status_code == HTTPStatus.BAD_REQUEST:
|
if e.status_code == HTTPStatus.BAD_REQUEST:
|
||||||
raise
|
raise
|
||||||
if e.status_code == HTTPStatus.UNAUTHORIZED:
|
elif e.status_code == HTTPStatus.UNAUTHORIZED:
|
||||||
|
# we pass this in case it is not an invoice key, nor an admin key, and then return NOT_FOUND at the end of this block
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue