mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-10 20:42:32 +02:00
refactor: use the new check_admin
This commit is contained in:
@@ -734,13 +734,8 @@ async def websocket_update_get(item_id: str, data: str):
|
|||||||
|
|
||||||
@core_app.post("/api/v1/extension/{ext_id}/{hash}")
|
@core_app.post("/api/v1/extension/{ext_id}/{hash}")
|
||||||
async def api_install_extension(
|
async def api_install_extension(
|
||||||
ext_id: str, hash: str, user: User = Depends(check_user_exists)
|
ext_id: str, hash: str, user: User = Depends(check_admin)
|
||||||
):
|
):
|
||||||
if not user.admin:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.UNAUTHORIZED, detail="Only for admin users"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
extension_list: List[InstallableExtension] = await get_installable_extensions()
|
extension_list: List[InstallableExtension] = await get_installable_extensions()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
@@ -852,12 +847,7 @@ async def api_install_extension(
|
|||||||
|
|
||||||
|
|
||||||
@core_app.delete("/api/v1/extension/{ext_id}")
|
@core_app.delete("/api/v1/extension/{ext_id}")
|
||||||
async def api_uninstall_extension(ext_id: str, user: User = Depends(check_user_exists)):
|
async def api_uninstall_extension(ext_id: str, user: User = Depends(check_admin)):
|
||||||
if not user.admin:
|
|
||||||
raise HTTPException(
|
|
||||||
status_code=HTTPStatus.UNAUTHORIZED, detail="Only for admin users"
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
extension_list: List[InstallableExtension] = await get_installable_extensions()
|
extension_list: List[InstallableExtension] = await get_installable_extensions()
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
Reference in New Issue
Block a user