fix: use check_user_exists for LNbits 1.4 compatibility
Some checks failed
CI / lint (push) Waiting to run
CI / tests (3.10) (push) Blocked by required conditions
CI / tests (3.9) (push) Blocked by required conditions
CI / lint (pull_request) Has been cancelled
/ release (push) Has been cancelled
CI / tests (3.10) (pull_request) Has been cancelled
CI / tests (3.9) (pull_request) Has been cancelled
/ pullrequest (push) Has been cancelled
Some checks failed
CI / lint (push) Waiting to run
CI / tests (3.10) (push) Blocked by required conditions
CI / tests (3.9) (push) Blocked by required conditions
CI / lint (pull_request) Has been cancelled
/ release (push) Has been cancelled
CI / tests (3.10) (pull_request) Has been cancelled
CI / tests (3.9) (pull_request) Has been cancelled
/ pullrequest (push) Has been cancelled
LNbits 1.4 changed check_super_user to return Account (no wallets) instead of User (with wallets). This broke the template rendering because LNbits.map.user() requires the wallets property. Switch to check_user_exists (returns User with wallets) and manually check user.super_user for access control. This follows the same pattern used by LNbits core admin pages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
25be6cff87
commit
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.
|
||||
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from http import HTTPStatus
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
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
|
||||
|
||||
satmachineadmin_generic_router = APIRouter()
|
||||
|
|
@ -15,7 +17,11 @@ def satmachineadmin_renderer():
|
|||
|
||||
# DCA Admin page - Requires superuser access
|
||||
@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(
|
||||
"satmachineadmin/index.html", {"request": req, "user": user.json()}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue