Bug 18025: Simplify logic and avoid 1 call to ValidateBorrowernumber
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 15 Feb 2017 17:14:11 +0000 (17:14 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 17 Feb 2017 11:24:39 +0000 (11:24 +0000)
Signed-off-by: Liz Rea <liz@catalyst.net.nz>
This is fine with me.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
opac/opac-password-recovery.pl

index 2099caf..8c76015 100755 (executable)
@@ -90,16 +90,14 @@ if ( $query->param('sendEmail') || $query->param('resendEmail') ) {
         }
 
 # Check if a password reset already issued for this borrower AND we are not asking for a new email
-        elsif ( ValidateBorrowernumber( $borrower->borrowernumber )
-            && !$query->param('resendEmail') )
-        {
-            $hasError                = 1;
-            $errAlreadyStartRecovery = 1;
-        }
-        elsif ( !ValidateBorrowernumber($borrower->borrowernumber)
-            && !$query->param('resendEmail') )
-        {
-            DeleteExpiredPasswordRecovery($borrower->borrowernumber);
+        elsif ( not $query->param('resendEmail') ) {
+            if ( ValidateBorrowernumber( $borrower->borrowernumber ) ) {
+                $hasError                = 1;
+                $errAlreadyStartRecovery = 1;
+            }
+            else {
+                DeleteExpiredPasswordRecovery( $borrower->borrowernumber );
+            }
         }
     }
     else {    # 0 matching borrower