From f48d0e62ca428877233e86bde8ad6ab72aa427df Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 23 Apr 2016 17:01:24 +0100 Subject: [PATCH] [SIGNED-OFF] 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. --- 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 2dc63f5..f02ff0d 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 75ecdc3..d817f5c 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -323,7 +323,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