feat: better wording
This commit is contained in:
@@ -3,8 +3,10 @@ from uuid import uuid4
|
|||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
|
from lnbits.core.crud.settings import set_settings_field
|
||||||
from lnbits.core.db import db
|
from lnbits.core.db import db
|
||||||
from lnbits.core.models.extensions import UserExtension
|
from lnbits.core.models.extensions import UserExtension
|
||||||
|
from lnbits.core.models.users import RegisterUser
|
||||||
from lnbits.db import Connection
|
from lnbits.db import Connection
|
||||||
from lnbits.settings import (
|
from lnbits.settings import (
|
||||||
EditableSettings,
|
EditableSettings,
|
||||||
@@ -192,3 +194,22 @@ async def init_admin_settings(super_user: str | None = None) -> SuperSettings:
|
|||||||
|
|
||||||
editable_settings = EditableSettings.from_dict(settings.dict())
|
editable_settings = EditableSettings.from_dict(settings.dict())
|
||||||
return await create_admin_settings(account.id, editable_settings.dict())
|
return await create_admin_settings(account.id, editable_settings.dict())
|
||||||
|
|
||||||
|
|
||||||
|
async def check_register_activation_settings(data: RegisterUser):
|
||||||
|
if not settings.lnbits_require_user_activation:
|
||||||
|
return None
|
||||||
|
if settings.lnbits_user_activation_by_invitation_code and data.invitation_code:
|
||||||
|
code = data.invitation_code.strip()
|
||||||
|
if code == settings.lnbits_register_reusable_activation_code:
|
||||||
|
return None
|
||||||
|
if code in settings.lnbits_register_one_time_activation_codes:
|
||||||
|
settings.lnbits_register_one_time_activation_codes.remove(code)
|
||||||
|
await set_settings_field(
|
||||||
|
"lnbits_register_one_time_activation_codes",
|
||||||
|
settings.lnbits_register_one_time_activation_codes,
|
||||||
|
)
|
||||||
|
return None
|
||||||
|
raise ValueError("Invalid invitation code.")
|
||||||
|
|
||||||
|
raise ValueError("No activation method provided.")
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ from fastapi.responses import JSONResponse, RedirectResponse
|
|||||||
from fastapi_sso.sso.base import OpenID, SSOBase
|
from fastapi_sso.sso.base import OpenID, SSOBase
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from lnbits.core.crud.settings import set_settings_field
|
|
||||||
from lnbits.core.crud.users import (
|
from lnbits.core.crud.users import (
|
||||||
get_user_access_control_lists,
|
get_user_access_control_lists,
|
||||||
update_user_access_control_list,
|
update_user_access_control_list,
|
||||||
@@ -27,7 +26,10 @@ from lnbits.core.models.users import (
|
|||||||
UpdateAccessControlList,
|
UpdateAccessControlList,
|
||||||
)
|
)
|
||||||
from lnbits.core.services import create_user_account
|
from lnbits.core.services import create_user_account
|
||||||
from lnbits.core.services.users import update_user_account
|
from lnbits.core.services.users import (
|
||||||
|
check_register_activation_settings,
|
||||||
|
update_user_account,
|
||||||
|
)
|
||||||
from lnbits.decorators import (
|
from lnbits.decorators import (
|
||||||
access_token_payload,
|
access_token_payload,
|
||||||
check_account_exists,
|
check_account_exists,
|
||||||
@@ -379,25 +381,6 @@ async def register(data: RegisterUser) -> JSONResponse:
|
|||||||
return _auth_success_response(account.username, account.id, account.email)
|
return _auth_success_response(account.username, account.id, account.email)
|
||||||
|
|
||||||
|
|
||||||
async def check_register_activation_settings(data: RegisterUser):
|
|
||||||
if not settings.lnbits_require_user_activation:
|
|
||||||
return None
|
|
||||||
if settings.lnbits_user_activation_by_invitation_code and data.invitation_code:
|
|
||||||
code = data.invitation_code.strip()
|
|
||||||
if code == settings.lnbits_register_reusable_activation_code:
|
|
||||||
return None
|
|
||||||
if code in settings.lnbits_register_one_time_activation_codes:
|
|
||||||
settings.lnbits_register_one_time_activation_codes.remove(code)
|
|
||||||
await set_settings_field(
|
|
||||||
"lnbits_register_one_time_activation_codes",
|
|
||||||
settings.lnbits_register_one_time_activation_codes,
|
|
||||||
)
|
|
||||||
return None
|
|
||||||
raise ValueError("Invalid invitation code.")
|
|
||||||
|
|
||||||
raise ValueError("No activation method provided.")
|
|
||||||
|
|
||||||
|
|
||||||
@auth_router.put("/pubkey")
|
@auth_router.put("/pubkey")
|
||||||
async def update_pubkey(
|
async def update_pubkey(
|
||||||
data: UpdateUserPubkey,
|
data: UpdateUserPubkey,
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -720,8 +720,8 @@ window.localisation.en = {
|
|||||||
one_time_activation_code_label: 'Add activation code',
|
one_time_activation_code_label: 'Add activation code',
|
||||||
one_time_activation_code_hint:
|
one_time_activation_code_hint:
|
||||||
'List of one-time activation codes. Each code can be used only once, then will be reomved from the list.',
|
'List of one-time activation codes. Each code can be used only once, then will be reomved from the list.',
|
||||||
confirmation_code: 'Confirmation Code',
|
invitation_code: 'Invitation Code',
|
||||||
confirmation_code_hint: 'The confirmation code that you have received.',
|
invitation_code_hint: 'The invitation code that you have received.',
|
||||||
email: 'Email',
|
email: 'Email',
|
||||||
email_confirmation_hint: 'Email address to send the confirmation code to.',
|
email_confirmation_hint: 'Email address to send the confirmation code to.',
|
||||||
nostr_identifier: 'Nostr Identifier',
|
nostr_identifier: 'Nostr Identifier',
|
||||||
|
|||||||
@@ -814,17 +814,6 @@ include('components/lnbits-error.vue') %}
|
|||||||
type="password"
|
type="password"
|
||||||
:rules="[val => !val || val.length >= 8 || $t('invalid_password')]"
|
:rules="[val => !val || val.length >= 8 || $t('invalid_password')]"
|
||||||
></q-input>
|
></q-input>
|
||||||
<div
|
|
||||||
v-if="confirmationMethodsCount > 0"
|
|
||||||
class="q-my-md q-pa-sm text-body2 text-grey-4 bg-grey-9 rounded-borders"
|
|
||||||
>
|
|
||||||
<q-icon name="info" color="orange-4" class="q-mr-xs"></q-icon>
|
|
||||||
|
|
||||||
Confirmation required before you can log in.
|
|
||||||
<div v-if="confirmationMethodsCount > 1">
|
|
||||||
Please choose one of the methods below.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
v-if="confirmationMethodsCount > 1"
|
v-if="confirmationMethodsCount > 1"
|
||||||
class="row justify-center q-mb-md"
|
class="row justify-center q-mb-md"
|
||||||
@@ -864,14 +853,20 @@ include('components/lnbits-error.vue') %}
|
|||||||
<div v-if="confirmationMethodsCount > 0" class="q-mb-md">
|
<div v-if="confirmationMethodsCount > 0" class="q-mb-md">
|
||||||
<q-tab-panels v-model="confirmationMethod">
|
<q-tab-panels v-model="confirmationMethod">
|
||||||
<q-tab-panel name="code" class="q-pa-none">
|
<q-tab-panel name="code" class="q-pa-none">
|
||||||
|
<div
|
||||||
|
class="q-my-md q-pa-sm text-body2 text-grey-4 bg-grey-9 rounded-borders"
|
||||||
|
>
|
||||||
|
<q-icon name="info" color="orange-4" class="q-mr-xs"></q-icon>
|
||||||
|
You need an invitation code to register.
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
filled
|
filled
|
||||||
v-model="confirmationCode"
|
v-model="confirmationCode"
|
||||||
:label="$t('confirmation_code')"
|
:label="$t('invitation_code')"
|
||||||
:type="showConfirmationCode ? 'text' : 'password'"
|
:type="showConfirmationCode ? 'text' : 'password'"
|
||||||
:hint="$t('confirmation_code_hint')"
|
:hint="$t('invitation_code_hint')"
|
||||||
>
|
>
|
||||||
<q-btn
|
<q-btn
|
||||||
@click="showConfirmationCode = !showConfirmationCode"
|
@click="showConfirmationCode = !showConfirmationCode"
|
||||||
@@ -889,6 +884,13 @@ include('components/lnbits-error.vue') %}
|
|||||||
<div>payment</div>
|
<div>payment</div>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
<q-tab-panel name="nostr" class="q-pa-none">
|
<q-tab-panel name="nostr" class="q-pa-none">
|
||||||
|
<div
|
||||||
|
class="q-my-md q-pa-sm text-body2 text-grey-4 bg-grey-9 rounded-borders"
|
||||||
|
>
|
||||||
|
<q-icon name="info" color="orange-4" class="q-mr-xs"></q-icon>
|
||||||
|
You will receive a confirmation link at the provided Nostr
|
||||||
|
identifier or NPub.
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<q-input
|
<q-input
|
||||||
dense
|
dense
|
||||||
|
|||||||
Reference in New Issue
Block a user