add possibility to turn off new registrations (#2017)

with LNBITS_ALLOW_NEW_ACCOUNTS=false

while keeping existing users functional (i.e. no allowlist for existing users)
This commit is contained in:
Pavol Rusnak
2023-10-11 13:46:27 +02:00
committed by GitHub
parent b2384c10cc
commit ba0e431199
6 changed files with 20 additions and 6 deletions
+3 -1
View File
@@ -3,6 +3,7 @@
{% endblock %} {% block page %}
<div class="row q-col-gutter-md justify-center">
<div class="col-12 col-md-7 col-lg-6 q-gutter-y-md">
{% if lnurl or LNBITS_NEW_ACCOUNTS_ALLOWED %}
<q-card>
<q-card-section>
{% if lnurl %}
@@ -14,7 +15,7 @@
href="{{ url_for('core.lnurlwallet') }}?lightning={{ lnurl }}"
v-text="$t('press_to_claim')"
></q-btn>
{% else %}
{% elif LNBITS_NEW_ACCOUNTS_ALLOWED %}
<q-form @submit="createWallet" class="q-gutter-md">
<q-input
filled
@@ -33,6 +34,7 @@
{% endif %}
</q-card-section>
</q-card>
{% endif %}
<q-card>
<q-card-section>
+1 -1
View File
@@ -172,7 +172,7 @@ async def api_create_wallet(
@api_router.post("/api/v1/account", response_model=Wallet)
async def api_create_account(data: CreateWallet) -> Wallet:
if len(settings.lnbits_allowed_users) > 0:
if not settings.new_accounts_allowed:
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,
detail="Account creation is disabled.",
+1
View File
@@ -51,6 +51,7 @@ def template_renderer(additional_folders: Optional[List] = None) -> Jinja2Templa
t.env.globals["LNBITS_THEME_OPTIONS"] = settings.lnbits_theme_options
t.env.globals["LNBITS_QR_LOGO"] = settings.lnbits_qr_logo
t.env.globals["LNBITS_VERSION"] = settings.version
t.env.globals["LNBITS_NEW_ACCOUNTS_ALLOWED"] = settings.new_accounts_allowed
t.env.globals["LNBITS_ADMIN_UI"] = settings.lnbits_admin_ui
t.env.globals["LNBITS_NODE_UI"] = (
settings.lnbits_node_ui and get_node_class() is not None
+5
View File
@@ -35,6 +35,11 @@ class LNbitsSettings(BaseModel):
class UsersSettings(LNbitsSettings):
lnbits_admin_users: List[str] = Field(default=[])
lnbits_allowed_users: List[str] = Field(default=[])
lnbits_allow_new_accounts: bool = Field(default=True)
@property
def new_accounts_allowed(self) -> bool:
return self.lnbits_allow_new_accounts and len(self.lnbits_allowed_users) == 0
class ExtensionsSettings(LNbitsSettings):