From ab4e3d6b125e3772d19523e3e81d96422c195452 Mon Sep 17 00:00:00 2001 From: padreug Date: Mon, 5 Jan 2026 12:14:48 +0100 Subject: [PATCH] fix: use check_user_exists for LNbits 1.4 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/views.py b/views.py index 61701cd..6532836 100644 --- a/views.py +++ b/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()} ) -- 2.52.0