[%# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. #%] [% inline_style = BLOCK %] .field-hr, .field-row { clear: both; } .field-row { height: 2.5em; } .field-name { text-align: right; width: 150px; float: left; padding-top: 2px; font-weight: bold; } .field-value { margin-left: 160px; } #errors, #complexity_rules { margin-left: 160px; max-width: 500px; } #errors { color: #dd4848; position: absolute; margin-left: 500px; } #errors ul { padding: 0; margin: 0; } #complexity_rules { margin-bottom: 50px; } [% END %] [% inline_js = BLOCK %] $(function() { $('#old_password, #new_password1, #new_password2') .keyup(function() { var errors = []; var old = $('#old_password').val(); var new1 = $('#new_password1').val(); var new2 = $('#new_password2').val(); if (old === '') { errors.push('Missing current password'); } if (new1 === '' || new2 === '') { errors.push('Missing new password'); } else if (new1 !== new2) { errors.push('New passwords do not match'); } else if (new1 === old) { errors.push('Your new password must be different from your old password'); } else if (new1.length < [% constants.USER_PASSWORD_MIN_LENGTH FILTER none %]) { errors.push('Your password must be at least [% constants.USER_PASSWORD_MIN_LENGTH FILTER none %] long'); } else { var complexity_fn; [% SWITCH Param('password_complexity') %] [% CASE 'no_constraints' %] complexity_fn = function() {}; [% CASE 'mixed_letters' %] complexity_fn = function(pass, errors) { if ( pass.search(/[a-z]/) == -1 || pass.search(/[A-Z]/) == -1 ) { errors.push('New password is not complex enough'); } }; [% CASE 'letters_numbers' %] complexity_fn = function(pass, errors) { if ( pass.search(/[a-z]/) == -1 || pass.search(/[A-Z]/) == -1 || pass.search(/[0-9]/) == -1 ) { errors.push('New password is not complex enough'); } }; [% CASE 'letters_numbers_specialchars' %] complexity_fn = function(pass, errors) { if ( pass.search(/[a-z]/) == -1 || pass.search(/[A-Z]/) == -1 || pass.search(/[0-9]/) == -1 || pass.search(/\W/) == -1 ) { errors.push('New password is not complex enough'); } }; [% END %] complexity_fn(new1, errors); } $('#submit').attr('disabled', errors.length > 0); if ((old !== '' || new1 !== '' || new2 !== '') && errors.length) { $('#errors').html('
[% user.password_change_reason || "You are required to update your password." FILTER html %]
Your password must be a minimum of [% constants.USER_PASSWORD_MIN_LENGTH FILTER none %] characters long [% SWITCH Param('password_complexity') %] [% CASE 'mixed_letters' %] and must contain at least one UPPER and one lowercase letter [% CASE 'letters_numbers' %] and must contain at least one UPPER and one lowercase letter and a number [% CASE 'letters_numbers_specialchars' %] and must contain at least one letter, a number and a special character [% END ~%].
[% PROCESS global/footer.html.tmpl %]