Fix sso disabled password inconsistencies

main
Igor Scheller 3 years ago committed by msquare
parent 8fd2d5bfa5
commit b5ba5f6188

@ -250,8 +250,8 @@ return [
'min_password_length' => env('PASSWORD_MINIMUM_LENGTH', 8), 'min_password_length' => env('PASSWORD_MINIMUM_LENGTH', 8),
// Whether the Password field should be enabled on registration. // Whether the Password field should be enabled on registration.
// If this is disabled, it means that no password can be set on registration so the user will // This is useful when using oauth, disabling it also disables normal
// not be able to log in unless linked to an oauth provider. // registration without oauth.
'enable_password' => (bool)env('ENABLE_PASSWORD', true), 'enable_password' => (bool)env('ENABLE_PASSWORD', true),
// Whether the DECT field should be enabled // Whether the DECT field should be enabled

@ -37,6 +37,7 @@ function guest_register()
$config = config(); $config = config();
$request = request(); $request = request();
$session = session(); $session = session();
$is_oauth = $session->has('oauth2_connect_provider');
$msg = ''; $msg = '';
$nick = ''; $nick = '';
@ -76,8 +77,10 @@ function guest_register()
} }
if ( if (
!auth()->can('register') !auth()->can('register') // No registration permission
|| (!$authUser && !config('registration_enabled') && !$session->get('oauth2_allow_registration')) // Not authenticated and
|| (!$authUser && !config('registration_enabled') && !$session->get('oauth2_allow_registration')) // Registration disabled
|| (!$authUser && !$enable_password && !$is_oauth) // Password disabled and not oauth
) { ) {
error(__('Registration is disabled.')); error(__('Registration is disabled.'));

@ -188,6 +188,9 @@ msgstr "Passwort vergessen"
msgid "Please sign up, if you want to help us!" msgid "Please sign up, if you want to help us!"
msgstr "Bitte registriere Dich, wenn Du helfen möchtest!" msgstr "Bitte registriere Dich, wenn Du helfen möchtest!"
msgid "Registration is only available via external login."
msgstr "Die Registrierung ist nur über einen externen Login möglich."
#: resources/views/pages/login.twig:90 includes/pages/guest_login.php:61 #: resources/views/pages/login.twig:90 includes/pages/guest_login.php:61
msgid "Registration is disabled." msgid "Registration is disabled."
msgstr "Registrierung ist abgeschaltet." msgstr "Registrierung ist abgeschaltet."

@ -100,8 +100,12 @@
<div class="col-sm-6 text-center"> <div class="col-sm-6 text-center">
<h2>{{ __('Register') }}</h2> <h2>{{ __('Register') }}</h2>
{% if has_permission_to('register') and config('registration_enabled') %} {% if has_permission_to('register') and config('registration_enabled') %}
{% if config('enable_password') %}
<p>{{ __('Please sign up, if you want to help us!') }}</p> <p>{{ __('Please sign up, if you want to help us!') }}</p>
<a href="{{ url('register') }}" class="btn btn-primary">{{ __('Register') }} &raquo;</a> <a href="{{ url('register') }}" class="btn btn-primary">{{ __('Register') }} &raquo;</a>
{% else %}
<p>{{ __('Registration is only available via external login.') }}</p>
{% endif %}
{% else %} {% else %}
{{ m.alert(__('Registration is disabled.'), 'danger') }} {{ m.alert(__('Registration is disabled.'), 'danger') }}
{% endif %} {% endif %}

Loading…
Cancel
Save