From b5ba5f61882746f0aa8ec3da34b01d2e42063ed8 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Fri, 10 Dec 2021 01:51:04 +0100 Subject: [PATCH] Fix sso disabled password inconsistencies --- config/config.default.php | 4 ++-- includes/pages/guest_login.php | 7 +++++-- resources/lang/de_DE/default.po | 3 +++ resources/views/pages/login.twig | 8 ++++++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index b76b5857..323a7b2d 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -250,8 +250,8 @@ return [ 'min_password_length' => env('PASSWORD_MINIMUM_LENGTH', 8), // 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 - // not be able to log in unless linked to an oauth provider. + // 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 diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php index e422aeb3..c4596af1 100644 --- a/includes/pages/guest_login.php +++ b/includes/pages/guest_login.php @@ -37,6 +37,7 @@ function guest_register() $config = config(); $request = request(); $session = session(); + $is_oauth = $session->has('oauth2_connect_provider'); $msg = ''; $nick = ''; @@ -76,8 +77,10 @@ function guest_register() } if ( - !auth()->can('register') - || (!$authUser && !config('registration_enabled') && !$session->get('oauth2_allow_registration')) + !auth()->can('register') // No registration permission + // 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.')); diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po index 770c0123..0576d45c 100644 --- a/resources/lang/de_DE/default.po +++ b/resources/lang/de_DE/default.po @@ -188,6 +188,9 @@ msgstr "Passwort vergessen" msgid "Please sign up, if you want to help us!" 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 msgid "Registration is disabled." msgstr "Registrierung ist abgeschaltet." diff --git a/resources/views/pages/login.twig b/resources/views/pages/login.twig index 95220b1d..2b8a3846 100644 --- a/resources/views/pages/login.twig +++ b/resources/views/pages/login.twig @@ -100,8 +100,12 @@

{{ __('Register') }}

{% if has_permission_to('register') and config('registration_enabled') %} -

{{ __('Please sign up, if you want to help us!') }}

- {{ __('Register') }} » + {% if config('enable_password') %} +

{{ __('Please sign up, if you want to help us!') }}

+ {{ __('Register') }} » + {% else %} +

{{ __('Registration is only available via external login.') }}

+ {% endif %} {% else %} {{ m.alert(__('Registration is disabled.'), 'danger') }} {% endif %}