diff --git a/src/AdminCabinet/Plugins/NotFoundPlugin.php b/src/AdminCabinet/Plugins/NotFoundPlugin.php index 1d938aaa7..2f680e9f7 100644 --- a/src/AdminCabinet/Plugins/NotFoundPlugin.php +++ b/src/AdminCabinet/Plugins/NotFoundPlugin.php @@ -58,6 +58,14 @@ public function beforeException( ] ); + return false; + case DispatcherException::EXCEPTION_CYCLIC_ROUTING: + $dispatcher->forward( + [ + 'controller' => 'errors', + 'action' => 'show500', + ] + ); return false; } } diff --git a/src/AdminCabinet/Plugins/SecurityPlugin.php b/src/AdminCabinet/Plugins/SecurityPlugin.php index a21031433..00bce88dd 100644 --- a/src/AdminCabinet/Plugins/SecurityPlugin.php +++ b/src/AdminCabinet/Plugins/SecurityPlugin.php @@ -116,16 +116,6 @@ private function redirectToHome(Dispatcher $dispatcher): void{ $homePath='/admin-cabinet/extensions/index'; } - $currentPageCacheKey = 'redirectCount'.md5($homePath); - $redirectCount = $this->session->get($currentPageCacheKey)??0; - $redirectCount++; - $this->session->set($currentPageCacheKey, $redirectCount); - if ($redirectCount > 5){ - $this->session->set($currentPageCacheKey, 0); - $this->forwardTo401Error($dispatcher); - return; - } - // Extract the module, controller, and action from the home page path $module = explode('/', $homePath)[1]; $controller = explode('/', $homePath)[2]; @@ -155,7 +145,7 @@ private function redirectToHome(Dispatcher $dispatcher): void{ * Redirects the user to a 401 error page. * @param $dispatcher Dispatcher instance for handling the redirection. */ - private function forwardTo401Error($dispatcher): void{ + private function forwardTo401Error(Dispatcher $dispatcher): void{ $dispatcher->forward([ 'module' => 'admin-cabinet', 'controller' => 'errors', @@ -168,7 +158,7 @@ private function forwardTo401Error($dispatcher): void{ * Redirects the user to the login page. * @param $dispatcher Dispatcher instance for handling the redirection. */ - private function forwardToLoginPage($dispatcher): void{ + private function forwardToLoginPage(Dispatcher $dispatcher): void{ $dispatcher->forward([ 'controller' => 'session', 'action' => 'index',