Add external_register_url to link to external registration site, hide password form if enable_password is false

Our users have problems with the disabled register button and
keep creating tickets. Add option to link to external site instead
of a disabled button.

People get confused by the login form if they should only
use the oauth login.
Now the login form is hidden if enable_password is false.
It can be shown by clicking the welcome text, in case an
admin needs access
This commit is contained in:
Daniel Poelzleithner 2023-08-04 01:27:38 +02:00 committed by xuwhite
parent ab967c6f9c
commit 0155a33beb
5 changed files with 34 additions and 19 deletions

View File

@ -256,6 +256,9 @@ return [
// Users are able to sign up
'registration_enabled' => (bool) env('REGISTRATION_ENABLED', true),
// URL to external registration page, used on login page
'external_registration_url' => env('EXTERNAL_REGISTRATION_URL'),
// Required user fields
'required_user_fields' => [
'pronoun' => (bool) env('PRONOUN_REQUIRED', false),
@ -300,9 +303,8 @@ return [
// The minimum length for passwords
'min_password_length' => env('PASSWORD_MINIMUM_LENGTH', 8),
// Whether the Password field should be enabled on registration.
// This is useful when using oauth, disabling it also disables normal
// registration without oauth.
// Whether the login and registration via password should be enabled (login will be hidden)
// This is useful when using oauth, disabling it also disables normal registration without oauth
'enable_password' => (bool) env('ENABLE_PASSWORD', true),
// Whether the DECT field should be enabled

View File

@ -360,7 +360,7 @@ ready(() => {
*/
ready(() => {
[
['welcome-title', '.btn-group .btn.d-none'],
['welcome-title', '.registration .d-none'],
['settings-title', '.user-settings .nav-item'],
['oauth-settings-title', 'table tr.d-none'],
].forEach(([id, selector]) => {

View File

@ -63,7 +63,12 @@
{% include "layouts/parts/language_dropdown.twig" %}
{% if has_permission_to('register') and config('registration_enabled') %}
{{ _self.toolbar_item(__('general.register'), url('/register'), 'register', 'plus') }}
{{ _self.toolbar_item(
__('general.register'),
config('external_registration_url') ?: url('/register'),
'register',
'plus'
) }}
{% endif %}
{% if has_permission_to('login') %}

View File

@ -15,7 +15,10 @@
</a>
{% else %}
{% if has_permission_to('register') and config('registration_enabled') %}
<a href="{{ url('/register') }}" class="btn btn-secondary back">
<a
href="{{ config('external_registration_url') ?: url('/register') }}"
class="btn btn-secondary back"
>
{{ __('registration.register') }}
</a>
{% endif %}

View File

@ -30,7 +30,8 @@
<div class="row mb-5">
<div class="col-md-6 offset-md-3 col-lg-4 offset-lg-4">
<div class="card {{ m.type_bg_class() }}">
<div class="card {{ m.type_bg_class() }} registration">
{% set login_hidden = not config('enable_password') %}
<div class="card-body">
{% include 'layouts/parts/messages.twig' %}
@ -40,7 +41,7 @@
<form action="" enctype="multipart/form-data" method="post">
{{ csrf() }}
<div class="mb-3">
<div class="mb-3{% if login_hidden %} d-none{% endif %}">
<div class="input-group input-group-lg">
<span class="input-group-text {{ m.type_text_class() }}">
{{ m.angel }}
@ -56,7 +57,7 @@
</div>
</div>
<div class="mb-3">
<div class="mb-3{% if login_hidden %} d-none{% endif %}">
<div class="input-group input-group-lg">
<span class="input-group-text {{ m.type_text_class() }}">
<i class="bi bi-key"></i>
@ -68,7 +69,7 @@
</div>
</div>
<div class="mb-3 text-center">
<div class="mb-3 text-center{% if login_hidden %} d-none{% endif %}">
<button class="btn btn-primary btn-lg btn-block" type="submit" name="submit">
{{ __('general.login') }}
</button>
@ -89,7 +90,7 @@
</div>
{% endif %}
<div class="text-center">
<div class="text-center{% if login_hidden %} d-none{% endif %}">
<a href="{{ url('/password/reset') }}" class="">
{{ __('login.password.reset') }}
</a>
@ -103,16 +104,20 @@
<div class="row mb-5">
<div class="col-sm-6 text-center">
<h2>{{ __('general.register') }}</h2>
{% if has_permission_to('register') and config('registration_enabled') %}
{% if config('enable_password') %}
{% if
(has_permission_to('register') and config('registration_enabled') and config('enable_password'))
or config('external_registration_url') %}
<p>{{ __('login.registration') }}</p>
<a href="{{ url('/register') }}" class="btn btn-primary">{{ __('general.register') }} &raquo;</a>
{% set registration_url = config('external_registration_url') ?: url('/register') %}
<a href="{{ registration_url }}" class="btn btn-primary">{{ __('general.register') }} &raquo;</a>
{% else %}
{% if not config('enable_password') %}
<p>{{ __('login.registration.external') }}</p>
{% endif %}
{% else %}
{{ m.alert(__('login.registration.disabled'), 'danger') }}
{% endif %}
{% endif %}
</div>
<div class="col-sm-6 text-center">