diff --git a/lnbits/core/crud.py b/lnbits/core/crud.py index ad2d9f2c..3066b124 100644 --- a/lnbits/core/crud.py +++ b/lnbits/core/crud.py @@ -1,15 +1,15 @@ -import json import datetime -from uuid import uuid4 -from typing import List, Optional, Dict, Any +import json +from typing import Any, Dict, List, Optional from urllib.parse import urlparse +from uuid import uuid4 from lnbits import bolt11 -from lnbits.db import Connection, POSTGRES, COCKROACH -from lnbits.settings import DEFAULT_WALLET_NAME +from lnbits.db import COCKROACH, POSTGRES, Connection +from lnbits.settings import DEFAULT_WALLET_NAME, LNBITS_ADMIN_USERS from . import db -from .models import User, Wallet, Payment, BalanceCheck +from .models import BalanceCheck, Payment, User, Wallet # accounts # -------- @@ -53,6 +53,7 @@ async def get_user(user_id: str, conn: Optional[Connection] = None) -> Optional[ """, (user_id,), ) + else: return None @@ -61,6 +62,7 @@ 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 LNBITS_ADMIN_USERS ) diff --git a/lnbits/core/views/generic.py b/lnbits/core/views/generic.py index d917ffab..d2fd8f41 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_ALLOWED_USERS, LNBITS_ADMIN_USERS, + LNBITS_ALLOWED_USERS, LNBITS_SITE_TITLE, SERVICE_FEE, ) @@ -118,8 +118,6 @@ 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]