allow user settings without restart
This commit is contained in:
parent
f16ead4f73
commit
5a3ad81c31
|
@ -15,7 +15,9 @@ from lnbits.core import db
|
|||
from lnbits.core.models import User
|
||||
from lnbits.decorators import check_user_exists
|
||||
from lnbits.helpers import template_renderer, url_for
|
||||
from lnbits.requestvars import g
|
||||
from lnbits.settings import (
|
||||
LNBITS_ADMIN_UI,
|
||||
LNBITS_ADMIN_USERS,
|
||||
LNBITS_ALLOWED_USERS,
|
||||
LNBITS_CUSTOM_LOGO,
|
||||
|
@ -37,7 +39,6 @@ from ..services import pay_invoice, redeem_lnurl_withdraw
|
|||
|
||||
core_html_routes: APIRouter = APIRouter(tags=["Core NON-API Website Routes"])
|
||||
|
||||
|
||||
@core_html_routes.get("/favicon.ico", response_class=FileResponse)
|
||||
async def favicon():
|
||||
return FileResponse("lnbits/core/static/favicon.ico")
|
||||
|
@ -119,6 +120,10 @@ async def wallet(
|
|||
wallet_name = nme
|
||||
service_fee = int(SERVICE_FEE) if int(SERVICE_FEE) == SERVICE_FEE else SERVICE_FEE
|
||||
|
||||
if LNBITS_ADMIN_UI:
|
||||
LNBITS_ADMIN_USERS = g().admin_conf.admin_users
|
||||
LNBITS_ALLOWED_USERS = g().admin_conf.allowed_users
|
||||
|
||||
if not user_id:
|
||||
user = await get_user((await create_account()).id)
|
||||
logger.info(f"Create user {user.id}") # type: ignore
|
||||
|
|
|
@ -16,6 +16,7 @@ from lnbits.core.models import User, Wallet
|
|||
from lnbits.requestvars import g
|
||||
from lnbits.settings import (
|
||||
LNBITS_ADMIN_EXTENSIONS,
|
||||
LNBITS_ADMIN_UI,
|
||||
LNBITS_ADMIN_USERS,
|
||||
LNBITS_ALLOWED_USERS,
|
||||
)
|
||||
|
@ -138,6 +139,9 @@ async def get_key_type(
|
|||
detail="Invoice (or Admin) key required.",
|
||||
)
|
||||
|
||||
if LNBITS_ADMIN_UI:
|
||||
LNBITS_ADMIN_USERS = g().admin_conf.admin_users
|
||||
|
||||
for typenr, WalletChecker in zip(
|
||||
[0, 1], [WalletAdminKeyChecker, WalletInvoiceKeyChecker]
|
||||
):
|
||||
|
@ -232,6 +236,10 @@ async def check_user_exists(usr: UUID4) -> User:
|
|||
status_code=HTTPStatus.NOT_FOUND, detail="User does not exist."
|
||||
)
|
||||
|
||||
if LNBITS_ADMIN_UI:
|
||||
LNBITS_ADMIN_USERS = g().admin_conf.admin_users
|
||||
LNBITS_ALLOWED_USERS = g().admin_conf.allowed_users
|
||||
|
||||
if LNBITS_ALLOWED_USERS and g().user.id not in LNBITS_ALLOWED_USERS:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.UNAUTHORIZED, detail="User not authorized."
|
||||
|
|
|
@ -24,6 +24,9 @@ class Extension(NamedTuple):
|
|||
|
||||
class ExtensionManager:
|
||||
def __init__(self):
|
||||
if settings.LNBITS_ADMIN_UI:
|
||||
settings.LNBITS_DISABLED_EXTENSIONS = g().admin_conf.disabled_ext
|
||||
settings.LNBITS_ADMIN_EXTENSIONS = g().admin_conf.admin_ext
|
||||
self._disabled: List[str] = settings.LNBITS_DISABLED_EXTENSIONS
|
||||
self._admin_only: List[str] = [
|
||||
x.strip(" ") for x in settings.LNBITS_ADMIN_EXTENSIONS
|
||||
|
|
Loading…
Reference in New Issue
Block a user