mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
Andrew Nicols
3778a9226f
MDL-53048 core_form: passwordunmask must exist on page for validation
The initial approach I took was to provide a noscript area containing the standard input element, and to move it to a hidden input element as part of the passwordunmask setup. This allowed behat tests to pass both with and without JS enabled (i.e. with Goutte and real browsers), and also ensured that the real input did not appear on screen. However, the standard formslib validation occurs before other page JS is run and hooks into the elements on page during its setup. Since noscript elements are not accessible to scripts as standard elements, the form validation would fail for _client_ side validation and work for server-side validation. This change creates creates the hidden input element in the template instead, as well as the password element in the noscript tag. Doing this means that when JS is disabled, the form has two elements of the same name - one hidden, and the second a visible password field. Since the latter element will always override the former one on form submission, and the noscript variant is last, the noscript variant wins when JS is disabled and tests continue to pass. When JS is enabled, the noscript variant is not a valid part of the DOM (the browser sees it as a hidden text field essentially). The password is not automatically entered into the hidden field, so the autocomplete prevention continues to work as expected.
…
…
…
…
…
.-..-. _____ | || | /____/-.---_ .---. .---. .-.| || | .---. | | _ _ |/ _ \/ _ \/ _ || |/ __ \ * | | | | | || |_| || |_| || |_| || || |___/ |_| |_| |_|\_____/\_____/\_____||_|\_____) Moodle - the world's open source learning platform Moodle <https://moodle.org> is a learning platform designed to provide educators, administrators and learners with a single robust, secure and integrated system to create personalised learning environments. You can download Moodle <https://download.moodle.org> and run it on your own web server, ask one of our Moodle Partners <https://moodle.com/partners/> to assist you, or have a MoodleCloud site <https://moodle.com/cloud/> set up for you. Moodle is widely used around the world by universities, schools, companies and all manner of organisations and individuals. Moodle is provided freely as open source software, under the GNU General Public License <https://docs.moodle.org/dev/License>. Moodle is written in PHP and JavaScript and uses an SQL database for storing the data. See <https://docs.moodle.org> for details of Moodle's many features.
Description
Languages
PHP
78.1%
JavaScript
14.6%
Gherkin
3.5%
CSS
1.7%
Mustache
1.6%
Other
0.4%