From b366f5476e881b8e0291cba5f662e6a325388a86 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 10 Apr 2024 03:22:30 -0700 Subject: [PATCH 1/7] Update Application.php --- lib/AppInfo/Application.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9b01565..2f97ba0 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -105,11 +105,13 @@ public function boot(IBootContext $context): void // redirecting to the logout url. $session->set('clearingExecutionContexts', '1'); $session->close(); - header('Clear-Site-Data: "cache", "storage"'); + if (!$this->isApiRequest()) { + header('Clear-Site-Data: "cache", "storage"'); - header('Location: '.$logoutUrl); + header('Location: '.$logoutUrl); - exit; + exit; + } }); } @@ -157,4 +159,8 @@ public function boot(IBootContext $context): void } } } + function isApiRequest() { + // Check if the request includes an 'Accept' header with value 'application/json' + return isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false; + } } From 2d711a9e422f4516bd8036f3c8542e450fc18ca5 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 10 Apr 2024 21:55:38 -0700 Subject: [PATCH 2/7] Update Application.php --- lib/AppInfo/Application.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 2f97ba0..af7d3ce 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -107,9 +107,7 @@ public function boot(IBootContext $context): void $session->close(); if (!$this->isApiRequest()) { header('Clear-Site-Data: "cache", "storage"'); - header('Location: '.$logoutUrl); - exit; } }); From 5d4e7e03de606943e083d49621e452c024a5a5b4 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Wed, 10 Apr 2024 21:58:16 -0700 Subject: [PATCH 3/7] Update Application.php --- lib/AppInfo/Application.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index af7d3ce..02eef08 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -105,11 +105,11 @@ public function boot(IBootContext $context): void // redirecting to the logout url. $session->set('clearingExecutionContexts', '1'); $session->close(); - if (!$this->isApiRequest()) { - header('Clear-Site-Data: "cache", "storage"'); - header('Location: '.$logoutUrl); - exit; - } + if (!$this->isApiRequest()) { + header('Clear-Site-Data: "cache", "storage"'); + header('Location: '.$logoutUrl); + exit; + } }); } @@ -157,8 +157,8 @@ public function boot(IBootContext $context): void } } } - function isApiRequest() { - // Check if the request includes an 'Accept' header with value 'application/json' - return isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false; - } + public function isApiRequest() { + // Check if the request includes an 'Accept' header with value 'application/json' + return isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false; + } } From 6fb3c72b93d20572de5371c285eed5597f059742 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 12 Apr 2024 16:22:08 -0700 Subject: [PATCH 4/7] php fixer --- lib/AppInfo/Application.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 02eef08..52a747c 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -105,11 +105,12 @@ public function boot(IBootContext $context): void // redirecting to the logout url. $session->set('clearingExecutionContexts', '1'); $session->close(); - if (!$this->isApiRequest()) { - header('Clear-Site-Data: "cache", "storage"'); - header('Location: '.$logoutUrl); - exit; - } + if (!$this->isApiRequest()) { + header('Clear-Site-Data: "cache", "storage"'); + header('Location: '.$logoutUrl); + + exit; + } }); } @@ -157,8 +158,10 @@ public function boot(IBootContext $context): void } } } - public function isApiRequest() { - // Check if the request includes an 'Accept' header with value 'application/json' - return isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false; - } + + public function isApiRequest() + { + // Check if the request includes an 'Accept' header with value 'application/json' + return isset($_SERVER['HTTP_ACCEPT']) && false !== strpos($_SERVER['HTTP_ACCEPT'], 'application/json'); + } } From 1c96a0c3c9c7b6c235b091743a6c88406c2b7728 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 12 Apr 2024 16:30:06 -0700 Subject: [PATCH 5/7] changed the code --- lib/AppInfo/Application.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 52a747c..9274a5e 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -161,7 +161,6 @@ public function boot(IBootContext $context): void public function isApiRequest() { - // Check if the request includes an 'Accept' header with value 'application/json' - return isset($_SERVER['HTTP_ACCEPT']) && false !== strpos($_SERVER['HTTP_ACCEPT'], 'application/json'); + return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 'xmlhttprequest' === strtolower($_SERVER['HTTP_X_REQUESTED_WITH']); } } From 50c859841f93fd0c6f2f01e1f945c0d38b29c209 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 12 Apr 2024 16:39:09 -0700 Subject: [PATCH 6/7] added ajax request --- lib/AppInfo/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9274a5e..9f67cc5 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -161,6 +161,6 @@ public function boot(IBootContext $context): void public function isApiRequest() { - return !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 'xmlhttprequest' === strtolower($_SERVER['HTTP_X_REQUESTED_WITH']); + return isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false; } } From 9fadd65b52b739aaac063a9e470508ac2313cf17 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Fri, 12 Apr 2024 18:34:39 -0700 Subject: [PATCH 7/7] change as php fixer --- lib/AppInfo/Application.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9f67cc5..5584226 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -161,6 +161,6 @@ public function boot(IBootContext $context): void public function isApiRequest() { - return isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false; + return isset($_SERVER['HTTP_ACCEPT']) && false !== strpos($_SERVER['HTTP_ACCEPT'], 'application/json'); } }