From e825b301e3a386dca0bdf03af1314aa41c756ccb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 26 Jul 2022 14:55:02 +0200 Subject: [PATCH] Bug 31244: [21.11.x] Fix 500 if logout and not logged in Can't use an undefined value as a HASH reference at /kohadevbox/koha/C4/Auth.pm line 985 C4::Auth::checkauth('CGI=HASH(0x5603b7dc4300)', 0, 'HASH(0x5603b2633238)', 'intranet', undef, 'intranet-main.tt') called at /kohadevbox/koha/C4/Auth.pm line 186 C4::Auth::get_template_and_user('HASH(0x5603b7b83d08)') called at /kohadevbox/koha/mainpage.pl line 40 Test plan: Open a private window Hit /cgi-bin/koha/mainpage.pl?logout.x=1 Signed-off-by: Sally Signed-off-by: Victor Grousset/tuxayo Rebased for 21.11.x Signed-off-by: Martin Renvoize --- C4/Auth.pm | 2 +- C4/Auth_with_shibboleth.pm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index e8e75b84ce..bb00ded4a9 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -912,7 +912,7 @@ sub checkauth { # voluntary logout the user # check wether the user was using their shibboleth session or a local one - my $shibSuccess = C4::Context->userenv->{'shibboleth'}; + my $shibSuccess = C4::Context->userenv ? C4::Context->userenv->{'shibboleth'} : undef; $session->delete(); $session->flush; $cookie = $cookie_mgr->clear_unless( $query->cookie, @$cookie ); diff --git a/C4/Auth_with_shibboleth.pm b/C4/Auth_with_shibboleth.pm index e214a5307c..10296c4323 100644 --- a/C4/Auth_with_shibboleth.pm +++ b/C4/Auth_with_shibboleth.pm @@ -54,6 +54,7 @@ sub logout_shib { my $uri = _get_uri(); my $return = _get_return($query); print $query->redirect( $uri . "/Shibboleth.sso/Logout?return=$return" ); + exit; } # Returns Shibboleth login URL with callback to the requesting URL -- 2.39.5