MDL-23692 forgotpw:adhere to site autocomp setting

This commit is contained in:
Peter Bulmer
2013-10-07 23:29:29 +13:00
parent 2f0dd8d5bd
commit 60a67d78e8
+9 -3
View File
@@ -43,13 +43,19 @@ class login_set_password_form extends moodleform {
*/
public function definition() {
global $USER, $CFG;
// Prepare a string showing whether the site wants login password autocompletion to be available to user.
if (empty($CFG->loginpasswordautocomplete)) {
$autocomplete = 'autocomplete="on"';
} else {
$autocomplete = '';
}
$mform = $this->_form;
$mform->setDisableShortforms(true);
$mform->addElement('header', 'setpassword', get_string('setpassword'), '');
// Include the username in the form so browsers will recognise that a password is being set.
$mform->addElement('text', 'username', '', 'style="display: none;" autocomplete="on"');
$mform->addElement('text', 'username', '', 'style="display: none;" ' . $autocomplete);
$mform->setType('username', PARAM_RAW);
// Token gives authority to change password.
$mform->addElement('hidden', 'token', '');
@@ -61,12 +67,12 @@ class login_set_password_form extends moodleform {
if (!empty($CFG->passwordpolicy)) {
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
}
$mform->addElement('password', 'password', get_string('newpassword'), 'autocomplete="on"');
$mform->addElement('password', 'password', get_string('newpassword'), $autocomplete);
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
$strpasswordagain = get_string('newpassword') . ' (' . get_string('again') . ')';
$mform->addElement('password', 'password2', $strpasswordagain, 'autocomplete="on"');
$mform->addElement('password', 'password2', $strpasswordagain, $autocomplete);
$mform->addRule('password2', get_string('required'), 'required', null, 'client');
$mform->setType('password2', PARAM_RAW);