From 961f8a6e0db87f201d1bc58d7f1da3f4a32f94db Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 23 Apr 2016 17:01:24 +0100 Subject: [PATCH] [PASSED QA] Bug 16275: Do not allow a self registration with an existing email address To avoid multiple registrations, it would be good to check the unicity of the primary email address. This patchset adds a new pref PatronSelfRegistrationEmailMustBeUnique. If on, a patron will get "This email address already exists in our database" if he try to register with an existing email address. Test plan: 1/ Register a new patron with an email address 2/ Make an other registration using the same email address => With the pref PatronSelfRegistrationEmailMustBeUnique on, you won't be allowed => With the pref off, no change should be noticed. Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Bernardo Gonzalez Kriegel Work as described, no errors. Signed-off-by: Nicolas Legrand Signed-off-by: Katrin Fischer --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt | 3 +++ opac/opac-memberentry.pl | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 574a5fd..1edbb95 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -64,6 +64,9 @@ [% IF field == "password_match" %]
  • Passwords do not match! 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 %] + [% IF field == "duplicate_email" %] +
  • This email address already exists in our database.
  • + [% END %] [% END %] Please correct the errors and resubmit. diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index b73ee1b..5a9195f 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -330,7 +330,14 @@ sub CheckForInvalidFields { my $borrower = shift; my @invalidFields; if ($borrower->{'email'}) { - push(@invalidFields, "email") if (!Email::Valid->address($borrower->{'email'})); + unless ( Email::Valid->address($borrower->{'email'}) ) { + push(@invalidFields, "email"); + } elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) { + my $patrons_with_same_email = Koha::Patrons->search( { email => $borrower->{email} })->count; + if ( $patrons_with_same_email ) { + push @invalidFields, "duplicate_email"; + } + } } if ($borrower->{'emailpro'}) { push(@invalidFields, "emailpro") if (!Email::Valid->address($borrower->{'emailpro'})); -- 1.9.1