Bug 21190: (follow-up) Save patron id in failure when available

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>
This commit is contained in:
Marcel de Rooy 2020-01-30 09:27:56 +00:00 committed by Martin Renvoize
parent a2f24f8e58
commit 73fd85fd02
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View 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;