Bug 18314: Fix reset number of login attempts on login success
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 28 Apr 2017 20:14:53 +0000 (17:14 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 12 May 2017 14:59:00 +0000 (10:59 -0400)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Auth.pm

index 74c2792..9e787c0 100644 (file)
@@ -1815,8 +1815,12 @@ sub checkpw {
 
     if ( $return[0] == 0 ) {
         $patron->update({ login_attempts => $patron->login_attempts + 1 }) if $patron;
-    } elsif ( $return[1] == 1 ) {
-        $patron->update({ login_attempts => 0 })->store if $patron;
+    } elsif ( $return[0] == 1 ) {
+        if ( $patron ) {
+            # FIXME Koha::Object->update should return a Koha::Object to allow chaining
+            $patron->update({ login_attempts => 0 });
+            $patron->store;
+        }
     }
     return @return;
 }