From 111f993d97b3a74d749078d020b8e8703d611b62 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 8399bcdcc84..07afd24018a 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1774,6 +1774,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.34.1