MDL-71176 login: Add html5 autocomplete attributes
This implementation will include the correct autocomplete attribute value so that the password managers can aid in creating good secure passwords and not get confused with other autocomplete types. There are some changes the password type form so that autocomplete attribute can be passed an array.
This commit is contained in:
committed by
Safat Shahin
parent
a747fd3055
commit
bc76ab4742
@@ -57,9 +57,9 @@ class MoodleQuickForm_password extends HTML_QuickForm_password implements templa
|
||||
// no standard mform in moodle should allow autocomplete of passwords
|
||||
if (empty($attributes)) {
|
||||
$attributes = array('autocomplete'=>'off');
|
||||
} else if (is_array($attributes)) {
|
||||
} else if (is_array($attributes) && empty($attributes['autocomplete'])) {
|
||||
$attributes['autocomplete'] = 'off';
|
||||
} else {
|
||||
} else if (is_string($attributes)) {
|
||||
if (strpos($attributes, 'autocomplete') === false) {
|
||||
$attributes .= ' autocomplete="off" ';
|
||||
}
|
||||
|
||||
@@ -58,11 +58,14 @@ class login_change_password_form extends moodleform {
|
||||
$mform->addRule('password', get_string('required'), 'required', null, 'client');
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
$mform->addElement('password', 'newpassword1', get_string('newpassword'));
|
||||
$mform->addElement('password', 'newpassword1', get_string('newpassword'),
|
||||
['autocomplete' => 'new-password']);
|
||||
$mform->addRule('newpassword1', get_string('required'), 'required', null, 'client');
|
||||
$mform->setType('newpassword1', PARAM_RAW);
|
||||
|
||||
$mform->addElement('password', 'newpassword2', get_string('newpassword').' ('.get_String('again').')');
|
||||
$mform->addElement('password', 'newpassword2',
|
||||
get_string('newpassword').' ('.get_String('again').')',
|
||||
['autocomplete' => 'new-password']);
|
||||
$mform->addRule('newpassword2', get_string('required'), 'required', null, 'client');
|
||||
$mform->setType('newpassword2', PARAM_RAW);
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ class login_signup_form extends moodleform implements renderable, templatable {
|
||||
|
||||
$mform->addElement('header', 'createuserandpass', get_string('createuserandpass'), '');
|
||||
|
||||
|
||||
$mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12" autocapitalize="none"');
|
||||
$mform->setType('username', PARAM_RAW);
|
||||
$mform->addRule('username', get_string('missingusername'), 'required', null, 'client');
|
||||
@@ -46,7 +45,11 @@ class login_signup_form extends moodleform implements renderable, templatable {
|
||||
if (!empty($CFG->passwordpolicy)){
|
||||
$mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy());
|
||||
}
|
||||
$mform->addElement('password', 'password', get_string('password'), 'maxlength="32" size="12"');
|
||||
$mform->addElement('password', 'password', get_string('password'), [
|
||||
'maxlength' => 32,
|
||||
'size' => 12,
|
||||
'autocomplete' => 'new-password'
|
||||
]);
|
||||
$mform->setType('password', core_user::get_property_type('password'));
|
||||
$mform->addRule('password', get_string('missingpassword'), 'required', null, 'client');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user