Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| ab4e3d6b12 |
1 changed files with 9 additions and 3 deletions
12
views.py
12
views.py
|
|
@ -1,9 +1,11 @@
|
||||||
# Description: DCA Admin page endpoints.
|
# Description: DCA Admin page endpoints.
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, Request
|
from http import HTTPStatus
|
||||||
|
|
||||||
|
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import HTMLResponse
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
from lnbits.decorators import check_super_user
|
from lnbits.decorators import check_user_exists
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
|
||||||
satmachineadmin_generic_router = APIRouter()
|
satmachineadmin_generic_router = APIRouter()
|
||||||
|
|
@ -15,7 +17,11 @@ def satmachineadmin_renderer():
|
||||||
|
|
||||||
# DCA Admin page - Requires superuser access
|
# DCA Admin page - Requires superuser access
|
||||||
@satmachineadmin_generic_router.get("/", response_class=HTMLResponse)
|
@satmachineadmin_generic_router.get("/", response_class=HTMLResponse)
|
||||||
async def index(req: Request, user: User = Depends(check_super_user)):
|
async def index(req: Request, user: User = Depends(check_user_exists)):
|
||||||
|
if not user.super_user:
|
||||||
|
raise HTTPException(
|
||||||
|
HTTPStatus.FORBIDDEN, "User not authorized. No super user privileges."
|
||||||
|
)
|
||||||
return satmachineadmin_renderer().TemplateResponse(
|
return satmachineadmin_renderer().TemplateResponse(
|
||||||
"satmachineadmin/index.html", {"request": req, "user": user.json()}
|
"satmachineadmin/index.html", {"request": req, "user": user.json()}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue