@@ -, +, @@
---
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt | 3 ++-
opac/opac-memberentry.pl | 3 +++
t/db_dependent/Members.t | 5 ++++-
3 files changed, 9 insertions(+), 2 deletions(-)
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt
+++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt
@@ -61,7 +61,8 @@
[% IF field == "emailpro" %]
Contact information: secondary email address[% END %]
[% IF field == "B_email" %]Alternate address information: email address[% END %]
[% IF field == "password_match" %]Passwords do not match! password[% END %]
- [% IF field == "password_invalid" %]Password does not meet minium requirements! password[% END %]
+ [% IF field == "password_invalid" %]Password does not meet minimum requirements! password[% END %]
+ [% IF field == "password_spaces" %]Password contains leading and/or trailing spaces! password[% END %]
[% END %]
Please correct the errors and resubmit.
--- a/opac/opac-memberentry.pl
+++ a/opac/opac-memberentry.pl
@@ -326,6 +326,9 @@ sub CheckForInvalidFields {
if ( $borrower->{'password'} && $minpw && (length($borrower->{'password'}) < $minpw) ) {
push(@invalidFields, "password_invalid");
}
+ if ( $borrower->{'password'} ) {
+ push(@invalidFields, "password_spaces") if ($borrower->{'password'} =~ /^\s/ or $borrower->{'password'} =~ /\s$/);
+ }
return \@invalidFields;
}
--- a/t/db_dependent/Members.t
+++ a/t/db_dependent/Members.t
@@ -17,7 +17,7 @@
use Modern::Perl;
-use Test::More tests => 76;
+use Test::More tests => 77;
use Test::MockModule;
use Data::Dumper;
use C4::Context;
@@ -371,6 +371,9 @@ my $password="";
is( $password =~ /^[a-zA-Z]{10}$/ , 1, 'Test for autogenerated password if none submitted');
( $borrowernumber, $password ) = AddMember_Opac(surname=>"Deckard",firstname=>"Rick",password=>"Nexus-6",branchcode => $library2->{branchcode});
is( $password eq "Nexus-6", 1, 'Test password used if submitted');
+$borrower = GetMember(borrowernumber => $borrowernumber);
+my $hashed_up = Koha::AuthUtils::hash_password("Nexus-6", $borrower->{password});
+is( $borrower->{password} eq $hashed_up, 1, 'Check password hash equals hash of submitted password' );
--