Bug 22458: Don't check for duplicate email on borrower self modification
This patch adds an extra variable to internal function CheckValidBorrower to set the
context as 'create' or 'update'
To test:
1 - Enable PatronSelfRegistrationEmailMustBeUnique
2 - Edit a patron in staff interface and set email to 'a@example.org'
3 - Open an incognito window and go to opac
4 - Self register a patron using email a@example.org
5 - You receive an error
6 - Use b@example.org for email
7 - No problem
8 - Sign in as the new patron
9 - Edit your information
10 - Set email to a@example.org
11 - You receive an error
12 - Apply patch, restart all
13 - Edit patron again
14 - No error!
15 - Register another patron on the opac
16 - Confirm still wanred if using a@example.org as the email
Signed-off-by: Allax Guillen <AGuillen@roseville.ca.us>
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 5cf5811d01)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
5a8e5cefc4
commit
8fa13778c2
|
|
@ -136,7 +136,7 @@ if ( $op eq 'cud-create' ) {
|
|||
$borrower{categorycode} ||= $PatronSelfRegistrationDefaultCategory;
|
||||
|
||||
my @empty_mandatory_fields = (CheckMandatoryFields( \%borrower, $op ), CheckMandatoryAttributes( \%borrower, $attributes ) );
|
||||
my $invalidformfields = CheckForInvalidFields(\%borrower);
|
||||
my $invalidformfields = CheckForInvalidFields( { borrower => \%borrower, context => 'create' } );
|
||||
delete $borrower{'password2'};
|
||||
my $is_cardnumber_valid;
|
||||
if ( !grep { $_ eq 'cardnumber' } @empty_mandatory_fields ) {
|
||||
|
|
@ -315,7 +315,7 @@ elsif ( $op eq 'cud-update' ) {
|
|||
|
||||
my @empty_mandatory_fields = grep { $_ ne 'password' } # password is not required when editing personal details
|
||||
( CheckMandatoryFields( \%borrower, $op ), CheckMandatoryAttributes( \%borrower, $attributes ) );
|
||||
my $invalidformfields = CheckForInvalidFields(\%borrower);
|
||||
my $invalidformfields = CheckForInvalidFields( { borrower => \%borrower, context => 'update' } );
|
||||
|
||||
# Send back the data to the template
|
||||
%borrower = ( %$borrower, %borrower );
|
||||
|
|
@ -485,12 +485,14 @@ sub CheckMandatoryAttributes{
|
|||
}
|
||||
|
||||
sub CheckForInvalidFields {
|
||||
my $borrower = shift;
|
||||
my $params = shift;
|
||||
my $borrower = $params->{borrower};
|
||||
my $context = $params->{context};
|
||||
my @invalidFields;
|
||||
if ($borrower->{'email'}) {
|
||||
unless ( Koha::Email->is_valid($borrower->{email}) ) {
|
||||
push(@invalidFields, "email");
|
||||
} elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) {
|
||||
} elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") && $context eq 'create' ) {
|
||||
my $patrons_with_same_email = Koha::Patrons->search( # FIXME Should be search_limited?
|
||||
{
|
||||
email => $borrower->{email},
|
||||
|
|
|
|||
Loading…
Reference in New Issue