From 21f262fdeaab62f6b699dbc512596423001c18ef Mon Sep 17 00:00:00 2001 From: Timothy Alexis Vass Date: Mon, 24 Aug 2020 10:38:22 +0200 Subject: [PATCH] Bug 26266: Add jQuery validator to opac-password-recovery.tt To test: 1) Initiate password recovery. 2) Try to enter an invalid password. 3) Confirm that validation occurs. 4) Try to enter mismatching passwords. 5) Confirm that validation occurs. 6) Sign off. --- .../bootstrap/en/includes/password_check.inc | 2 +- .../en/modules/opac-password-recovery.tt | 41 ++++++++----------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc index 1a94309ae8..aff757fe36 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/password_check.inc @@ -18,7 +18,7 @@ return ( this.optional(element) || !value.match(/^\s/) && !value.match(/\s$/) ); }, _("Password contains leading and/or trailing spaces")); jQuery.validator.addMethod("password_match", function(value, element){ - var new_password_node = $("input[name='" + new_password_node_name + "']:first"); + var new_password_node = $("#" + new_password_node_name); return this.optional(element) || value == $(new_password_node).val(); }, _("Please enter the same password as above")); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-password-recovery.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-password-recovery.tt index 3485202225..4a7eec3d37 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-password-recovery.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-password-recovery.tt @@ -5,6 +5,9 @@ [% INCLUDE 'doc-head-close.inc' %] [% BLOCK cssinclude %][% END %] [% BLOCK jsinclude %] +[% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %] +[% PROCESS 'password_check.inc' %] +[% PROCESS 'add_password_check' new_password => 'password' %] [% END %] @@ -104,7 +121,7 @@ [% ELSIF (new_password) %] [% UNLESS ( errLinkNotValid ) %] -
+
[% IF ( Koha.Preference('RequireStrongPassword') ) %] @@ -145,25 +162,3 @@ [% INCLUDE 'opac-bottom.inc' %] -[% BLOCK jsinclude %] - [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %] - [% PROCESS 'password_check.inc' %] - [% PROCESS 'add_password_check' new_password => 'password' %] - -[% END %] -- 2.20.1