Bug 33815: Do not explode if logged in user modify their own userid

If the logged in librarian modifies their own userid they will get the
following error when submitting the form:
Can't call method "password_expired" on an undefined value at /kohadevbox/koha/C4/Auth.pm line 1780

We could handle this situation and flag the session as expired. Better
would be to deal with this specific user case and update the cookie (?)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 5da81cde99)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2023-05-24 09:29:30 +02:00 committed by Matt Blenkinsop
parent ea31cb1511
commit 11cc4871b0
1 changed files with 9 additions and 0 deletions

View File

@ -1773,6 +1773,15 @@ sub check_cookie_auth {
} elsif ( $userid ) {
$session->param( 'lasttime', time() );
my $patron = Koha::Patrons->find({ userid => $userid });
# If the user modify their own userid
# Better than 500 but we could do better
unless ( $patron ) {
$session->delete();
$session->flush;
return ("expired", undef);
}
$patron = Koha::Patrons->find({ cardnumber => $userid })
unless $patron;
return ("password_expired", undef ) if $patron->password_expired;