From ca971152de9ca35a6d7c6e781062c222a55a12b3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 14 Mar 2022 11:30:57 +0000 Subject: [PATCH] Bug 29957: Replace clear_all_cookies in Auth.pm Test plan: Enable language selection and have two languages. Change language. Check cookie value in browser for KohaOpacLanguage. Logout. Verify that cookie has been cleared in browser. Add do_not_remove_cookie line for KohaOpacLanguage in koha-conf. Restart, flush. Login again. Change language. Check cookie value in browser for KohaOpacLanguage. Logout. Verify that cookie still contains the language. Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers Signed-off-by: Kyle M Hall --- C4/Auth.pm | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 9b8590cd07..c181096546 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -48,6 +48,7 @@ use Encode; use C4::Auth_with_shibboleth qw( shib_ok get_login_shib login_shib_url logout_shib checkpw_shib ); use Net::CIDR; use C4::Log qw( logaction ); +use Koha::CookieManager; # use utf8; @@ -803,15 +804,6 @@ sub _timeout_syspref { return $timeout; } -sub clear_all_cookies { - my ( $query ) = shift; - my @cookies; - for my $cookie_name ( $query->cookie ) { - push @cookies, $query->cookie( -name => $cookie_name, -value => '', -expires => '', -HttpOnly => 1 ); - } - return \@cookies; -} - sub checkauth { my $query = shift; @@ -842,6 +834,8 @@ sub checkauth { my $dbh = C4::Context->dbh; my $timeout = _timeout_syspref(); + my $cookie_mgr = Koha::CookieManager->new; + _version_check( $type, $query ); # state variables @@ -917,7 +911,7 @@ sub checkauth { my $shibSuccess = C4::Context->userenv->{'shibboleth'}; $session->delete(); $session->flush; - $cookie = clear_all_cookies($query); + $cookie = $cookie_mgr->clear_unless( $query->cookie, @$cookie ); C4::Context::_unset_userenv($sessionID); $sessionID = undef; -- 2.39.5