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 <bgkriegel@gmail.com>
Work as described, no errors.

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2016-04-23 17:01:24 +01:00 committed by Kyle M Hall
parent f835f1f3bd
commit 23d5d0fbd3
2 changed files with 11 additions and 1 deletions

View File

@ -65,6 +65,9 @@
[% IF field == "password_match" %]<li>Passwords do not match! <a href="#password">password</a></li>[% END %]
[% IF field == "password_invalid" %]<li>Password does not meet minimum requirements! <a href="#password">password</a></li>[% END %]
[% IF field == "password_spaces" %]<li>Password contains leading and/or trailing spaces! <a href="#password">password</a></li>[% END %]
[% IF field == "duplicate_email" %]
<li>This email address already exists in our database.</li>
[% END %]
[% END %]
</ul>
Please correct the errors and resubmit.

View File

@ -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'}));