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>
[% 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.
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'}));