Bug 21190: (follow-up) Save patron id in failure when available
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 30 Jan 2020 09:27:56 +0000 (09:27 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 14 Apr 2020 15:13:39 +0000 (16:13 +0100)
The wrong password might belong to an existing user. If that is the case,
we have a $patron.
Note that logaction will save the object info but has no user in the
context environment for a failure.

Test plan:
Login with good user, bad pw and bad user, bad pw. Check logviewer.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

C4/Auth.pm

index e00d621..1f79ef6 100644 (file)
@@ -1868,7 +1868,7 @@ sub checkpw {
     if( $patron && $passwd_ok && C4::Context->preference('AuthSuccessLog') ) {
         logaction( 'AUTH', 'SUCCESS', $patron->id, "Valid password for $userid", $type );
     } elsif( !$passwd_ok && C4::Context->preference('AuthFailureLog') ) {
-        logaction( 'AUTH', 'FAILURE', 0, "Wrong password for $userid", $type );
+        logaction( 'AUTH', 'FAILURE', $patron ? $patron->id : 0, "Wrong password for $userid", $type );
     }
 
     return @return;