+
+ # If there is no given email, and there is no email on record
+ elsif ( !$email && !$firstNonEmptyEmail ) {
+ $hasError = 1;
+ $errNoBorrowerEmail = 1;
+ }
+
+ # Check if a password reset already issued for this
+ # borrower AND we are not asking for a new email
+ elsif ( not $query->param('resendEmail') ) {
+ if ( ValidateBorrowernumber( $borrower->borrowernumber ) ) {
+ $hasError = 1;
+ $errAlreadyStartRecovery = 1;
+ }
+ else {
+ DeleteExpiredPasswordRecovery( $borrower->borrowernumber );
+ }
+ }
+ # Set the $email, if we don't have one.
+ if ( !$hasError && !$email ) {
+ $email = $firstNonEmptyEmail;