From ffbc38105fafb49419c04c79737619b0dcf98828 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 24 May 2023 09:29:30 +0200 Subject: [PATCH] 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 (?) --- C4/Auth.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/C4/Auth.pm b/C4/Auth.pm index ba074bab462..96f48267b95 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1775,6 +1775,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; -- 2.25.1