From 23d5d0fbd37ea1d9598487c368db4424e4f281e4 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 23 Apr 2016 17:01:24 +0100 Subject: [PATCH] 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 Signed-off-by: Kyle M Hall --- .../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 77e17e31c7..66db3065c9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -65,6 +65,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 8b5ade944f..6dcc832693 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -352,7 +352,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'})); -- 2.39.5