From 7c64c6d7776eae8136f175d147e261817dbd2372 Mon Sep 17 00:00:00 2001 From: NicoDucou Date: Thu, 26 Oct 2023 14:59:58 +0200 Subject: [PATCH 1/2] User: fix password field in profile visible if needed to change email even if profile settings indicates not to show password - refs BT#21151 --- main/auth/profile.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/main/auth/profile.php b/main/auth/profile.php index d41a711b7a..3616518bc5 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -325,6 +325,16 @@ if (!empty($links) && } // PASSWORD, if auth_source is platform +$allow_users_to_change_email_with_no_password = true; +if (is_platform_authentication() && + api_get_setting('allow_users_to_change_email_with_no_password') == 'false' +) { + $allow_users_to_change_email_with_no_password = false; +} +if (!$allow_users_to_change_email_with_no_password) { + $passwordExtraCommentForPasswordChange = get_lang('ToChangeYourEmailMustTypeYourPassword') . ". "; +} + if ($showPassword && is_profile_editable() && api_get_setting('profile', 'password') === 'true' @@ -332,7 +342,7 @@ if ($showPassword && $form->addElement( 'password', 'password0', - [get_lang('Pass'), get_lang('TypeCurrentPassword')], + [get_lang('Pass'), $passwordExtraCommentForPasswordChange . get_lang('TypeCurrentPassword')], [ 'size' => 40, 'show_hide' => true, @@ -362,7 +372,16 @@ if ($showPassword && $form->addRule(['password1', 'password2'], get_lang('PassTwo'), 'compare'); $form->addPasswordRule('password1'); $form->addNoSamePasswordRule('password1', $currentUser); -} +} elseif (!$allow_users_to_change_email_with_no_password) { + $form->addElement( + 'password', + 'password0', + [get_lang('Pass'), $passwordExtraCommentForPasswordChange], + [ + 'size' => 40, + 'show_hide' => true, + ] + ); $form->addHtml($extraLink); From 41a099993461b7a19cccd00f66d4f6709479aad7 Mon Sep 17 00:00:00 2001 From: NicoDucou Date: Thu, 26 Oct 2023 15:41:54 +0200 Subject: [PATCH 2/2] fix syntax error from previous commit 7c64c6d7776eae8136f175d147e261817dbd2372 -refs BT#21151 --- main/auth/profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/auth/profile.php b/main/auth/profile.php index 3616518bc5..a174d0f993 100755 --- a/main/auth/profile.php +++ b/main/auth/profile.php @@ -382,7 +382,7 @@ if ($showPassword && 'show_hide' => true, ] ); - +} $form->addHtml($extraLink); $extraField = new ExtraField('user');