Fix: don't show register if new users not allowed (#3010)
* enforce allow new user flag on UI
* chore: bundle
* ensure we get a boolean
---------
Co-authored-by: dni ⚡ <office@dnilabs.com>
This commit is contained in:
parent
c5964436b5
commit
fe9b62e8a8
5 changed files with 30 additions and 9 deletions
|
|
@ -59,6 +59,9 @@
|
|||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
const ALLOWED_REGISTER = {{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }};
|
||||
</script>
|
||||
<script src="{{ static_url_for('static', 'js/index.js') }}"></script>
|
||||
{% endblock %} {% block page_container %}
|
||||
<q-page-container>
|
||||
|
|
@ -145,7 +148,7 @@
|
|||
{%else%}
|
||||
<username-password
|
||||
v-if="authMethod != 'user-id-only'"
|
||||
:allowed_new_users="{{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }}"
|
||||
:allowed_new_users="allowedRegister"
|
||||
:auth-methods="{{ LNBITS_AUTH_METHODS }}"
|
||||
:auth-action="authAction"
|
||||
v-model:user-name="username"
|
||||
|
|
@ -160,7 +163,10 @@
|
|||
class="text-center text-grey-6"
|
||||
v-if="authAction !== 'reset'"
|
||||
>
|
||||
<p v-if="authAction === 'login'" class="q-mb-none">
|
||||
<p
|
||||
v-if="authAction === 'login' && allowedRegister"
|
||||
class="q-mb-none"
|
||||
>
|
||||
Not registered? Create an
|
||||
<span
|
||||
class="text-secondary cursor-pointer"
|
||||
|
|
@ -168,7 +174,14 @@
|
|||
>Account</span
|
||||
>
|
||||
</p>
|
||||
<p v-else class="q-mb-none">
|
||||
<p
|
||||
v-else-if="authAction === 'login' && !allowedRegister"
|
||||
class="q-mb-none"
|
||||
>
|
||||
<span v-text="$t('new_user_not_allowed')"></span>
|
||||
</p>
|
||||
|
||||
<p v-else-if="authAction === 'register'" class="q-mb-none">
|
||||
Aready have an account?
|
||||
<span
|
||||
class="text-secondary cursor-pointer"
|
||||
|
|
@ -180,7 +193,7 @@
|
|||
</username-password>
|
||||
{% if "user-id-only" in LNBITS_AUTH_METHODS %}
|
||||
<user-id-only
|
||||
:allowed_new_users="{{ LNBITS_NEW_ACCOUNTS_ALLOWED | tojson }}"
|
||||
:allowed_new_users="allowedRegister"
|
||||
v-model:usr="usr"
|
||||
v-model:wallet="walletName"
|
||||
:auth-action="authAction"
|
||||
|
|
|
|||
2
lnbits/static/bundle.min.js
vendored
2
lnbits/static/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -514,6 +514,7 @@ window.localisation.en = {
|
|||
allowed_users_label: 'User ID',
|
||||
allow_creation_user: 'Allow creation of new users',
|
||||
allow_creation_user_desc: 'Allow creation of new users on the index page',
|
||||
new_user_not_allowed: 'Registration is disabled.',
|
||||
components: 'Components',
|
||||
long_running_endpoints: 'Top 5 Long Running Endpoints',
|
||||
http_request_methods: 'HTTP Request Methods',
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ window.app = Vue.createApp({
|
|||
description: ''
|
||||
},
|
||||
isUserAuthorized: false,
|
||||
authAction: Quasar.LocalStorage.getItem('lnbits.disclaimerShown')
|
||||
? 'login'
|
||||
: 'register',
|
||||
authAction: 'login',
|
||||
authMethod: 'username-password',
|
||||
usr: '',
|
||||
username: '',
|
||||
|
|
@ -104,6 +102,12 @@ window.app = Vue.createApp({
|
|||
},
|
||||
created() {
|
||||
this.description = SITE_DESCRIPTION
|
||||
this.allowedRegister = ALLOWED_REGISTER
|
||||
this.authAction =
|
||||
!this.allowedRegister ||
|
||||
Quasar.LocalStorage.getItem('lnbits.disclaimerShown')
|
||||
? 'login'
|
||||
: 'register'
|
||||
this.isUserAuthorized = !!this.$q.cookies.get('is_lnbits_user_authorized')
|
||||
const _acccess_cookies_for_safari_refresh_do_not_delete = document.cookie
|
||||
if (this.isUserAuthorized) {
|
||||
|
|
|
|||
|
|
@ -1259,7 +1259,7 @@
|
|||
</q-form>
|
||||
</q-card-section>
|
||||
<!-- REGISTER -->
|
||||
<q-card-section v-if="authAction === 'register'">
|
||||
<q-card-section v-if="allowed_new_users && authAction === 'register'">
|
||||
<q-form @submit="register" class="q-gutter-sm">
|
||||
<q-input
|
||||
dense
|
||||
|
|
@ -1302,6 +1302,9 @@
|
|||
</div>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
<q-card-section v-else-if="!allowed_new_users && authAction === 'register'">
|
||||
<h5 class="text-center" v-text="$t('new_user_not_allowed')"></h5>
|
||||
</q-card-section>
|
||||
<slot></slot>
|
||||
<!-- RESET -->
|
||||
<q-card-section v-if="authAction === 'reset'">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue