diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index e1539212e..ad2d9f2cc 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -1,15 +1,15 @@ -import datetime import json -from typing import Any, Dict, List, Optional -from urllib.parse import urlparse +import datetime from uuid import uuid4 +from typing import List, Optional, Dict, Any +from urllib.parse import urlparse from lnbits import bolt11 -from lnbits.db import COCKROACH, POSTGRES, Connection -from lnbits.settings import DEFAULT_WALLET_NAME, LNBITS_ADMIN_USERS +from lnbits.db import Connection, POSTGRES, COCKROACH +from lnbits.settings import DEFAULT_WALLET_NAME from . import db -from .models import BalanceCheck, Payment, User, Wallet +from .models import User, Wallet, Payment, BalanceCheck # accounts # -------- @@ -53,7 +53,6 @@ async def get_user(user_id: str, conn: Optional[Connection] = None) -> Optional[ """, (user_id,), ) - else: return None @@ -62,7 +61,6 @@ async def get_user(user_id: str, conn: Optional[Connection] = None) -> Optional[ email=user["email"], extensions=[e[0] for e in extensions], wallets=[Wallet(**w) for w in wallets], - admin=LNBITS_ADMIN_USERS and user["id"] in [x.strip() for x in LNBITS_ADMIN_USERS] ) diff --git a/lnbits/core/views/generic.py b/lnbits/core/views/generic.py index d2fd8f412..d917ffab8 100644 --- a/lnbits/core/views/generic.py +++ b/lnbits/core/views/generic.py @@ -15,8 +15,8 @@ from lnbits.core.models import User from lnbits.decorators import check_user_exists from lnbits.helpers import template_renderer, url_for from lnbits.settings import ( - LNBITS_ADMIN_USERS, LNBITS_ALLOWED_USERS, + LNBITS_ADMIN_USERS, LNBITS_SITE_TITLE, SERVICE_FEE, ) @@ -118,6 +118,8 @@ async def wallet( return template_renderer().TemplateResponse( "error.html", {"request": request, "err": "User not authorized."} ) + if LNBITS_ADMIN_USERS and user_id in LNBITS_ADMIN_USERS: + user.admin = True if not wallet_id: if user.wallets and not wallet_name: wallet = user.wallets[0]