MDL-80967 Authentication: Login page - Hide the login form

This commit is contained in:
Steve Massicotte
2024-05-07 16:03:28 -04:00
parent 67b2c43225
commit fd4ebbf932
4 changed files with 49 additions and 38 deletions
+2
View File
@@ -102,6 +102,8 @@ if ($hassiteconfig) {
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'),
+1
View File
@@ -186,6 +186,7 @@ class login implements renderable, templatable {
$data->recaptcha = $this->recaptcha;
$data->togglepassword = $this->togglepassword;
$data->smallscreensonly = $this->smallscreensonly;
$data->showloginform = get_config('core', 'showloginform') === false || get_config('core', 'showloginform');
return $data;
}
+4
View File
@@ -157,6 +157,10 @@ $string['selfregistration_help'] = 'If an authentication plugin, such as email-b
$string['settingmigrationmismatch'] = 'Values mismatch detected while correcting the plugin setting names! The authentication plugin \'{$a->plugin}\' had the setting \'{$a->setting}\' configured to \'{$a->legacy}\' under the legacy name and to \'{$a->current}\' under the current name. The latter value has been set as the valid one but you should check and confirm that it is expected.';
$string['sha1'] = 'SHA-1 hash';
$string['showguestlogin'] = 'You can hide or show the guest login button on the login page.';
$string['showloginform'] = 'Show the Moodle login form or not.';
$string['showloginform_desc'] = 'If your site uses authentication methods that don\'t require people to enter their email/username and password, such as OAuth2, you may want to hide the standard login form. This is not compatible with Manual accounts.
If you are unable to log in and you want to show the login form, you can change this config with the command line: php admin/cli/cfg.php --name=showloginform --set=1';
$string['stdchangepassword'] = 'Use standard page for changing password';
$string['stdchangepassword_expl'] = 'If the external authentication system allows password changes through Moodle, switch this to Yes. This setting overrides \'Change Password URL\'.';
$string['stdchangepassword_explldap'] = 'NOTE: It is recommended that you use LDAP over an SSL encrypted tunnel (ldaps://) if the LDAP server is remote.';
+42 -38
View File
@@ -24,6 +24,7 @@
* canloginasguest - Is guest login allowed?,
* canloginbyemail - Is login by email allowed?,
* cansignup - Signup allowed?,
* showloginform - Hide the standard login form if it not necessary (only OAuth2 for example)
* cookieshelpicon - cookies help icon details
* error - Any errors in the form?,
* info - Info notification to display,
@@ -47,6 +48,7 @@
"canloginasguest": "1",
"canloginbyemail": false,
"cansignup": true,
"showloginform": true,
"cookieshelpicon": {
"heading": "Cookies must be enabled in your browser",
"text": "<div class=\"no-overflow\">Two cookies are used on this site. Both died..</div>",
@@ -123,45 +125,47 @@
{{#cansignup}}
<a href="{{signupurl}}" class="sr-only">{{#str}} tocreatenewaccount {{/str}}</a>
{{/cansignup}}
<form class="login-form" action="{{loginurl}}" method="post" id="login">
<input id="anchor" type="hidden" name="anchor" value="">
<script>document.getElementById('anchor').value = location.hash;</script>
<input type="hidden" name="logintoken" value="{{logintoken}}">
<div class="login-form-username mb-3">
<label for="username" class="sr-only">
{{^canloginbyemail}}
{{#str}} username {{/str}}
{{/canloginbyemail}}
{{#canloginbyemail}}
{{#str}} usernameemail {{/str}}
{{/canloginbyemail}}
</label>
<input type="text" name="username" id="username" {{!
!}}class="form-control form-control-lg" {{!
!}}value="{{username}}" {{!
!}}placeholder="{{^canloginbyemail}}{{#cleanstr}}username{{/cleanstr}}{{/canloginbyemail}}{{!
!}}{{#canloginbyemail}}{{#cleanstr}}usernameemail{{/cleanstr}}{{/canloginbyemail}}" {{!
!}}autocomplete="username">
</div>
<div class="login-form-password mb-3">
<label for="password" class="sr-only">{{#str}} password {{/str}}</label>
<input type="password" name="password" id="password" value="" {{!
!}}class="form-control form-control-lg" {{!
!}}placeholder="{{#cleanstr}}password{{/cleanstr}}" {{!
!}}autocomplete="current-password">
</div>
{{#recaptcha}}
<div class="login-form-recaptcha mb-3">
{{{recaptcha}}}
{{#showloginform}}
<form class="login-form" action="{{loginurl}}" method="post" id="login">
<input id="anchor" type="hidden" name="anchor" value="">
<script>document.getElementById('anchor').value = location.hash;</script>
<input type="hidden" name="logintoken" value="{{logintoken}}">
<div class="login-form-username mb-3">
<label for="username" class="sr-only">
{{^canloginbyemail}}
{{#str}} username {{/str}}
{{/canloginbyemail}}
{{#canloginbyemail}}
{{#str}} usernameemail {{/str}}
{{/canloginbyemail}}
</label>
<input type="text" name="username" id="username" {{!
!}}class="form-control form-control-lg" {{!
!}}value="{{username}}" {{!
!}}placeholder="{{^canloginbyemail}}{{#cleanstr}}username{{/cleanstr}}{{/canloginbyemail}}{{!
!}}{{#canloginbyemail}}{{#cleanstr}}usernameemail{{/cleanstr}}{{/canloginbyemail}}" {{!
!}}autocomplete="username">
</div>
{{/recaptcha}}
<div class="login-form-submit mb-3">
<button class="btn btn-primary btn-lg" type="submit" id="loginbtn">{{#str}}login{{/str}}</button>
</div>
<div class="login-form-forgotpassword mb-3">
<a href="{{forgotpasswordurl}}">{{#str}}forgotaccount{{/str}}</a>
</div>
</form>
<div class="login-form-password mb-3">
<label for="password" class="sr-only">{{#str}} password {{/str}}</label>
<input type="password" name="password" id="password" value="" {{!
!}}class="form-control form-control-lg" {{!
!}}placeholder="{{#cleanstr}}password{{/cleanstr}}" {{!
!}}autocomplete="current-password">
</div>
{{#recaptcha}}
<div class="login-form-recaptcha mb-3">
{{{recaptcha}}}
</div>
{{/recaptcha}}
<div class="login-form-submit mb-3">
<button class="btn btn-primary btn-lg" type="submit" id="loginbtn">{{#str}}login{{/str}}</button>
</div>
<div class="login-form-forgotpassword mb-3">
<a href="{{forgotpasswordurl}}">{{#str}}forgotaccount{{/str}}</a>
</div>
</form>
{{/showloginform}}
{{#hasidentityproviders}}
<div class="login-divider"></div>
<div class="login-identityproviders">