From 7092a9d63a453b08be2d856ea07ad202e3b766d9 Mon Sep 17 00:00:00 2001 From: Muhammad Arnaldo Date: Thu, 19 Feb 2026 14:08:53 +0700 Subject: [PATCH] MDL-87553 admin: Consolidate login settings into dedicated admin page Creates new "Login" category and moves login-related settings into a unified loginsettings page. --- public/admin/settings/login.php | 155 +++++++++++++++++++++++++++++ public/admin/settings/plugins.php | 61 ------------ public/admin/settings/security.php | 7 -- public/admin/settings/top.php | 1 + public/lang/en/admin.php | 2 + 5 files changed, 158 insertions(+), 68 deletions(-) create mode 100644 public/admin/settings/login.php diff --git a/public/admin/settings/login.php b/public/admin/settings/login.php new file mode 100644 index 00000000000..06b59f6df40 --- /dev/null +++ b/public/admin/settings/login.php @@ -0,0 +1,155 @@ +. + +/** + * Login administration settings. + * + * @package core_admin + * @copyright 2026 Muhammad Arnaldo + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +if ($hassiteconfig) { + $temp = new admin_settingpage('loginsettings', new lang_string('loginsettings', 'admin')); + + // Force to show the login page for fresh installs. + $temp->add(new admin_setting_configcheckbox( + 'forcelogin', + new lang_string('forcelogin', 'admin'), + new lang_string('configforcelogin', 'admin'), + 1 + )); + + // Self registration. + $temp->add(new admin_setting_special_registerauth()); + + // Allow log in via email. + $temp->add(new admin_setting_configcheckbox( + 'authloginviaemail', + new lang_string('authloginviaemail', 'core_auth'), + new lang_string('authloginviaemail_desc', 'core_auth'), + 1, + )); + + // Autofocus login page form. + $temp->add(new admin_setting_configcheckbox( + 'loginpageautofocus', + new lang_string('loginpageautofocus', 'admin'), + new lang_string('loginpageautofocus_help', 'admin'), + 0 + )); + + // Guest login button. + $temp->add(new admin_setting_configselect( + 'guestloginbutton', + new lang_string('guestloginbutton', 'auth'), + new lang_string('showguestlogin', 'auth'), + '0', + [0 => new lang_string('hide'), 1 => new lang_string('show')], + )); + + // Alternate login URL. + $temp->add(new admin_setting_configtext( + 'alternateloginurl', + new lang_string('alternateloginurl', 'auth'), + new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url(), ENT_COMPAT)), + '' + )); + + // Display manual login form. + $temp->add(new admin_setting_configcheckbox( + 'showloginform', + new lang_string('showloginform', 'core_auth'), + new lang_string('showloginform_desc', 'core_auth'), + 1 + )); + + // Forgotten password URL. + $temp->add(new admin_setting_configtext( + 'forgottenpasswordurl', + new lang_string('forgottenpasswordurl', 'auth'), + new lang_string('forgottenpassword', 'auth'), + '', + PARAM_URL + )); + + // Instructions shown on the login page. + $temp->add(new admin_setting_confightmleditor( + 'auth_instructions', + new lang_string('instructions', 'auth'), + new lang_string('authinstructions', 'auth'), + '' + )); + + // Enable reCAPTCHA for login. + $temp->add(new admin_setting_configselect( + 'enableloginrecaptcha', + new lang_string('auth_loginrecaptcha', 'auth'), + new lang_string('auth_loginrecaptcha_desc', 'auth'), + 0, + [ + new lang_string('no'), + new lang_string('yes'), + ], + )); + + // Enable reCAPTCHA for forgot password. + $temp->add(new admin_setting_configcheckbox( + 'enableforgotpasswordrecaptcha', + new lang_string('auth_forgotpasswordrecaptcha', 'auth'), + new lang_string('auth_forgotpasswordrecaptcha_desc', 'auth'), + 0, + )); + + // ReCAPTCHA site key. + $setting = new admin_setting_configtext( + 'recaptchapublickey', + new lang_string('recaptchapublickey', 'admin'), + new lang_string('configrecaptchapublickey', 'admin'), + '', + PARAM_NOTAGS + ); + $setting->set_force_ltr(true); + $temp->add($setting); + + // ReCAPTCHA secret key. + $setting = new admin_setting_configtext( + 'recaptchaprivatekey', + new lang_string('recaptchaprivatekey', 'admin'), + new lang_string('configrecaptchaprivatekey', 'admin'), + '', + PARAM_NOTAGS + ); + $setting->set_force_ltr(true); + $temp->add($setting); + + // Password visibility toggle. + $temp->add(new admin_setting_configselect( + 'loginpasswordtoggle', + new lang_string('auth_loginpasswordtoggle', 'auth'), + new lang_string('auth_loginpasswordtoggle_desc', 'auth'), + TOGGLE_SENSITIVE_ENABLED, + [ + TOGGLE_SENSITIVE_DISABLED => get_string('disabled', 'admin'), + TOGGLE_SENSITIVE_ENABLED => get_string('enabled', 'admin'), + TOGGLE_SENSITIVE_SMALL_SCREENS_ONLY => get_string('smallscreensonly', 'admin'), + ], + )); + + $ADMIN->add('login', $temp); +} diff --git a/public/admin/settings/plugins.php b/public/admin/settings/plugins.php index 2f2949df803..636d6a62848 100644 --- a/public/admin/settings/plugins.php +++ b/public/admin/settings/plugins.php @@ -115,37 +115,14 @@ if ($hassiteconfig) { $temp = new admin_settingpage('manageauths', new lang_string('authsettings', 'admin')); $temp->add(new admin_setting_manageauths()); $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), '')); - $temp->add(new admin_setting_special_registerauth()); - $temp->add(new admin_setting_configcheckbox( - 'authloginviaemail', - new lang_string('authloginviaemail', 'core_auth'), - new lang_string('authloginviaemail_desc', 'core_auth'), - 1, - )); $temp->add(new admin_setting_configcheckbox('allowaccountssameemail', new lang_string('allowaccountssameemail', 'core_auth'), new lang_string('allowaccountssameemail_desc', 'core_auth'), 0)); $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0)); - $temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0)); - $temp->add(new admin_setting_configselect( - 'guestloginbutton', - new lang_string('guestloginbutton', 'auth'), - new lang_string('showguestlogin', 'auth'), - '0', - [ 0 => new lang_string('hide'), 1 => new lang_string('show')], - )); $options = array(0 => get_string('no'), 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 10 => 10, 20 => 20, 50 => 50); $temp->add(new admin_setting_configselect('limitconcurrentlogins', new lang_string('limitconcurrentlogins', 'core_auth'), new lang_string('limitconcurrentlogins_desc', 'core_auth'), 0, $options)); - $temp->add(new admin_setting_configtext('alternateloginurl', new lang_string('alternateloginurl', 'auth'), - new lang_string('alternatelogin', 'auth', htmlspecialchars(get_login_url(), ENT_COMPAT)), '')); - $temp->add(new admin_setting_configcheckbox('showloginform', new lang_string('showloginform', 'core_auth'), - new lang_string('showloginform_desc', 'core_auth'), 1)); - $temp->add(new admin_setting_configtext('forgottenpasswordurl', new lang_string('forgottenpasswordurl', 'auth'), - new lang_string('forgottenpassword', 'auth'), '', PARAM_URL)); - $temp->add(new admin_setting_confightmleditor('auth_instructions', new lang_string('instructions', 'auth'), - new lang_string('authinstructions', 'auth'), '')); $setting = new admin_setting_configtext('allowemailaddresses', new lang_string('allowemailaddresses', 'admin'), new lang_string('configallowemailaddresses', 'admin'), '', PARAM_NOTAGS); $setting->set_force_ltr(true); @@ -156,46 +133,8 @@ if ($hassiteconfig) { $temp->add($setting); $temp->add(new admin_setting_configcheckbox('verifychangedemail', new lang_string('verifychangedemail', 'admin'), new lang_string('configverifychangedemail', 'admin'), 1)); - // ReCaptcha. - $temp->add(new admin_setting_configselect('enableloginrecaptcha', - new lang_string('auth_loginrecaptcha', 'auth'), - new lang_string('auth_loginrecaptcha_desc', 'auth'), - 0, - [ - new lang_string('no'), - new lang_string('yes'), - ], - )); - - - // Forgot password ReCaptcha. - $temp->add(new admin_setting_configcheckbox( - 'enableforgotpasswordrecaptcha', - new lang_string('auth_forgotpasswordrecaptcha', 'auth'), - new lang_string('auth_forgotpasswordrecaptcha_desc', 'auth'), - 0, - )); - - $setting = new admin_setting_configtext('recaptchapublickey', new lang_string('recaptchapublickey', 'admin'), new lang_string('configrecaptchapublickey', 'admin'), '', PARAM_NOTAGS); - $setting->set_force_ltr(true); - $temp->add($setting); - $setting = new admin_setting_configtext('recaptchaprivatekey', new lang_string('recaptchaprivatekey', 'admin'), new lang_string('configrecaptchaprivatekey', 'admin'), '', PARAM_NOTAGS); - $setting->set_force_ltr(true); - $temp->add($setting); $ADMIN->add('authsettings', $temp); - // Toggle password visiblity icon. - $temp->add(new admin_setting_configselect('loginpasswordtoggle', - new lang_string('auth_loginpasswordtoggle', 'auth'), - new lang_string('auth_loginpasswordtoggle_desc', 'auth'), - TOGGLE_SENSITIVE_ENABLED, - [ - TOGGLE_SENSITIVE_DISABLED => get_string('disabled', 'admin'), - TOGGLE_SENSITIVE_ENABLED => get_string('enabled', 'admin'), - TOGGLE_SENSITIVE_SMALL_SCREENS_ONLY => get_string('smallscreensonly', 'admin'), - ], - )); - $temp = new admin_externalpage('authtestsettings', get_string('testsettings', 'core_auth'), new moodle_url("/auth/test_settings.php"), 'moodle/site:config', true); $ADMIN->add('authsettings', $temp); diff --git a/public/admin/settings/security.php b/public/admin/settings/security.php index 59b8043d3ca..f43943cfb44 100644 --- a/public/admin/settings/security.php +++ b/public/admin/settings/security.php @@ -39,13 +39,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page // "sitepolicies" settingpage $temp = new admin_settingpage('sitepolicies', new lang_string('sitepolicies', 'admin')); $temp->add(new admin_setting_configcheckbox('protectusernames', new lang_string('protectusernames', 'admin'), new lang_string('configprotectusernames', 'admin'), 1)); - // Force to show the login page for fresh installs. - $temp->add(new admin_setting_configcheckbox( - 'forcelogin', - new lang_string('forcelogin', 'admin'), - new lang_string('configforcelogin', 'admin'), - 1 - )); $temp->add(new admin_setting_configcheckbox('forceloginforprofiles', new lang_string('forceloginforprofiles', 'admin'), new lang_string('configforceloginforprofiles', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('forceloginforprofileimage', new lang_string('forceloginforprofileimage', 'admin'), new lang_string('forceloginforprofileimage_help', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('opentowebcrawlers', new lang_string('opentowebcrawlers', 'admin'), new lang_string('configopentowebcrawlers', 'admin'), 0)); diff --git a/public/admin/settings/top.php b/public/admin/settings/top.php index cbf475ad796..f2f1249c611 100644 --- a/public/admin/settings/top.php +++ b/public/admin/settings/top.php @@ -32,6 +32,7 @@ $ADMIN->add('root', new admin_category('badges', new lang_string('badges'), empt $ADMIN->add('root', new admin_category('h5p', new lang_string('h5p', 'core_h5p'))); $ADMIN->add('root', new admin_category('license', new lang_string('license'))); $ADMIN->add('root', new admin_category('location', new lang_string('location','admin'))); +$ADMIN->add('root', new admin_category('login', new lang_string('login', 'admin'))); $ADMIN->add('root', new admin_category('language', new lang_string('language'))); $ADMIN->add('root', new admin_category('messaging', new lang_string('messagingcategory', 'admin'))); $ADMIN->add('root', new admin_category('payment', new lang_string('payments', 'payment'))); diff --git a/public/lang/en/admin.php b/public/lang/en/admin.php index 6190bcc4951..77f0cb21ee5 100644 --- a/public/lang/en/admin.php +++ b/public/lang/en/admin.php @@ -852,10 +852,12 @@ $string['lockrequestcategory'] = 'Prevent category selection'; $string['log'] = 'Logs'; $string['logguests'] = 'Log guest access'; $string['logguests_help'] = 'This setting enables logging of actions by guest account and not logged in users. High profile sites may want to disable this logging for performance reasons. It is recommended to keep this setting enabled on production sites.'; +$string['login'] = 'Login'; $string['logininfoinsecurelayout'] = 'Display logged-in user in secure layout'; $string['logininfoinsecurelayout_desc'] = 'If enabled, the logged-in user\'s full name will be displayed in the navigation bar when attempting a quiz or other activity using secure layout.'; $string['loginpageautofocus'] = 'Autofocus login page form'; $string['loginpageautofocus_help'] = 'Enabling this option improves usability of the login page, but automatically focusing fields may be considered an accessibility issue.'; +$string['loginsettings'] = 'Login settings'; $string['loglifetime'] = 'Keep logs for'; $string['logo'] = 'Logo'; $string['logo_desc'] = 'A full logo to be used as decoration by some themes (such as core themes). This image can be quite high resolution because it will be scaled down for use (and cached for performance). Logos that are wider than they are high usually give better results.';