diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js index 44ea578517..75e230bd66 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js @@ -81,6 +81,12 @@ var myDate2=document.form.dateexpiry.value.split ('/'); } //end function +function check_password( password ) { + if ( password.match(/^\s/) || password.match(/\s$/)) { + return false; + } + return true; +} // function to test all fields in forms and nav in different forms(1 ,2 or 3) function check_form_borrowers(nav){ @@ -106,6 +112,11 @@ function check_form_borrowers(nav){ statut=1; } + if ( ! check_password( document.form.password.value ) ) { + message_champ += MSG_PASSWORD_CONTAINS_TRAILING_SPACES; + statut = 1; + } + //patrons form to test if you checked no to the question of double if (statut!=1 && document.form.check_member.value > 0 ) { if (!(document.form_double.answernodouble.checked)){ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt index 4cb04ef5d7..6b0e965575 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-password.tt @@ -4,13 +4,14 @@ diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-passwd.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-passwd.tt index b855cbfdf7..ed072749fd 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-passwd.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-passwd.tt @@ -37,6 +37,9 @@ [% IF ( WrongPass ) %] Your current password was entered incorrectly. If this problem persists, please ask a librarian to re-set your password for you. [% END %] + [% IF PasswordContainsTrailingSpaces %] + Your password contains leading and/or trailing spaces. + [% END %]

[% END # /IF Error_messages %] diff --git a/opac/opac-passwd.pl b/opac/opac-passwd.pl index 6eef122c5c..bf6b175831 100755 --- a/opac/opac-passwd.pl +++ b/opac/opac-passwd.pl @@ -55,7 +55,13 @@ if ( C4::Context->preference("OpacPasswordChange") ) { && $query->param('Confirm') ) { if ( goodkey( $dbh, $borrowernumber, $query->param('Oldkey') ) ) { - if ( $query->param('Newkey') eq $query->param('Confirm') + if ( $query->param('Newkey') =~ m|^\s+| or $query->param('Newkey') =~ m|\s+$| ) { + $template->param( + Error_messages => 1, + PasswordContainsTrailingSpaces => 1, + ); + } + elsif ( $query->param('Newkey') eq $query->param('Confirm') && length( $query->param('Confirm') ) >= $minpasslen ) { # Record password my $clave = hash_password( $query->param('Newkey') );