Compare commits
No commits in common. "v0.0.3" and "v0.0.2" have entirely different histories.
1 changed files with 3 additions and 9 deletions
12
views.py
12
views.py
|
|
@ -1,11 +1,9 @@
|
||||||
# Description: DCA Admin page endpoints.
|
# Description: DCA Admin page endpoints.
|
||||||
|
|
||||||
from http import HTTPStatus
|
from fastapi import APIRouter, Depends, Request
|
||||||
|
|
||||||
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_user_exists
|
from lnbits.decorators import check_super_user
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
|
||||||
satmachineadmin_generic_router = APIRouter()
|
satmachineadmin_generic_router = APIRouter()
|
||||||
|
|
@ -17,11 +15,7 @@ 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_user_exists)):
|
async def index(req: Request, user: User = Depends(check_super_user)):
|
||||||
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