Lines 43-48
my $errMultipleAccountsForEmail;
Link Here
|
43 |
my $errAlreadyStartRecovery; |
43 |
my $errAlreadyStartRecovery; |
44 |
my $errTooManyEmailFound; |
44 |
my $errTooManyEmailFound; |
45 |
my $errBadEmail; |
45 |
my $errBadEmail; |
|
|
46 |
my $errResetForbidden; |
46 |
|
47 |
|
47 |
#new password form error |
48 |
#new password form error |
48 |
my $errLinkNotValid; |
49 |
my $errLinkNotValid; |
Lines 74-109
if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
Link Here
|
74 |
$errMultipleAccountsForEmail = 1; |
75 |
$errMultipleAccountsForEmail = 1; |
75 |
} |
76 |
} |
76 |
elsif ( $borrower = $search_results->next() ) { # One matching borrower |
77 |
elsif ( $borrower = $search_results->next() ) { # One matching borrower |
77 |
my @emails = grep { $_ } ( $borrower->email, $borrower->emailpro, $borrower->B_email ); |
|
|
78 |
|
78 |
|
79 |
my $firstNonEmptyEmail; |
79 |
if ( $borrower->category->effective_reset_password ) { |
80 |
$firstNonEmptyEmail = $emails[0] if @emails; |
|
|
81 |
|
80 |
|
82 |
# Is the given email one of the borrower's ? |
81 |
my @emails = grep { $_ } ( $borrower->email, $borrower->emailpro, $borrower->B_email ); |
83 |
if ( $email && !( grep /^$email$/i, @emails ) ) { |
|
|
84 |
$hasError = 1; |
85 |
$errNoBorrowerFound = 1; |
86 |
} |
87 |
|
82 |
|
88 |
# If there is no given email, and there is no email on record |
83 |
my $firstNonEmptyEmail; |
89 |
elsif ( !$email && !$firstNonEmptyEmail ) { |
84 |
$firstNonEmptyEmail = $emails[0] if @emails; |
90 |
$hasError = 1; |
85 |
|
91 |
$errNoBorrowerEmail = 1; |
86 |
# Is the given email one of the borrower's ? |
92 |
} |
87 |
if ( $email && !( grep /^$email$/i, @emails ) ) { |
|
|
88 |
$hasError = 1; |
89 |
$errNoBorrowerFound = 1; |
90 |
} |
91 |
|
92 |
# If there is no given email, and there is no email on record |
93 |
elsif ( !$email && !$firstNonEmptyEmail ) { |
94 |
$hasError = 1; |
95 |
$errNoBorrowerEmail = 1; |
96 |
} |
93 |
|
97 |
|
94 |
# Check if a password reset already issued for this borrower AND we are not asking for a new email |
98 |
# Check if a password reset already issued for this |
95 |
elsif ( not $query->param('resendEmail') ) { |
99 |
# borrower AND we are not asking for a new email |
96 |
if ( ValidateBorrowernumber( $borrower->borrowernumber ) ) { |
100 |
elsif ( not $query->param('resendEmail') ) { |
97 |
$hasError = 1; |
101 |
if ( ValidateBorrowernumber( $borrower->borrowernumber ) ) { |
98 |
$errAlreadyStartRecovery = 1; |
102 |
$hasError = 1; |
|
|
103 |
$errAlreadyStartRecovery = 1; |
104 |
} |
105 |
else { |
106 |
DeleteExpiredPasswordRecovery( $borrower->borrowernumber ); |
107 |
} |
99 |
} |
108 |
} |
100 |
else { |
109 |
# Set the $email, if we don't have one. |
101 |
DeleteExpiredPasswordRecovery( $borrower->borrowernumber ); |
110 |
if ( !$hasError && !$email ) { |
|
|
111 |
$email = $firstNonEmptyEmail; |
102 |
} |
112 |
} |
103 |
} |
113 |
} |
104 |
# Set the $email, if we don't have one. |
114 |
else { |
105 |
if ( !$hasError && !$email ) { |
115 |
$hasError = 1; |
106 |
$email = $firstNonEmptyEmail; |
116 |
$errResetForbidden = 1; |
107 |
} |
117 |
} |
108 |
} |
118 |
} |
109 |
else { # 0 matching borrower |
119 |
else { # 0 matching borrower |
Lines 119-124
if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
Link Here
|
119 |
errBadEmail => $errBadEmail, |
129 |
errBadEmail => $errBadEmail, |
120 |
errNoBorrowerEmail => $errNoBorrowerEmail, |
130 |
errNoBorrowerEmail => $errNoBorrowerEmail, |
121 |
errMultipleAccountsForEmail => $errMultipleAccountsForEmail, |
131 |
errMultipleAccountsForEmail => $errMultipleAccountsForEmail, |
|
|
132 |
errResetForbidden => $errResetForbidden, |
122 |
password_recovery => 1, |
133 |
password_recovery => 1, |
123 |
email => HTML::Entities::encode($email), |
134 |
email => HTML::Entities::encode($email), |
124 |
username => $username |
135 |
username => $username |
125 |
- |
|
|