From 33046b80927403bb0ff76a3591e0f5055aa98873 Mon Sep 17 00:00:00 2001 From: Tymoteusz Motylewski Date: Thu, 27 Jul 2017 15:00:30 +0200 Subject: [PATCH] Add handling for redirects for logged in users If a user is logged in, but a page is configured to "hide at login" We now check "redirectError403LoggedInUserTo" TS config where you can configure e.g. user profile page uid. So a logged in user will be redirected to his profile after accessing a page which is hidden at login. --- Classes/Domain/Handler/RedirectErrorHandler.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Classes/Domain/Handler/RedirectErrorHandler.php b/Classes/Domain/Handler/RedirectErrorHandler.php index c828229..0170ba7 100644 --- a/Classes/Domain/Handler/RedirectErrorHandler.php +++ b/Classes/Domain/Handler/RedirectErrorHandler.php @@ -78,13 +78,13 @@ public function handleError(\R3H6\Error404page\Domain\Model\Error $error) if (!$error->getPid()) { return false; } - if ($this->frontendUser->isLoggedIn()) { - return false; - } /** @var \R3H6\Error404page\Configuration\PageTsConfig $pageTsConfig */ $pageTsConfig = $this->pageTsConfigManager->getPageTsConfig($error->getPid()); $parameter = (string) $pageTsConfig->get('redirectError403To'); + if ($this->frontendUser->isLoggedIn()) { + $parameter = (string) $pageTsConfig->get('redirectError403LoggedInUserTo'); + } if ($parameter === 'auto') { $loginPage = $this->pageRepository->findLoginPageForError($error); @@ -97,6 +97,7 @@ public function handleError(\R3H6\Error404page\Domain\Model\Error $error) if (MathUtility::canBeInterpretedAsInteger($parameter)) { $this->cacheTags[] = 'pageId_'.$parameter; + $this->cacheTags[] = 'loggedIn_' . (string)$this->frontendUser->isLoggedIn(); if ($this->frontendController->isDefaultType() === false) { $parameter .= ','.$this->frontendController->getType(); } @@ -110,10 +111,10 @@ public function handleError(\R3H6\Error404page\Domain\Model\Error $error) if ($parameter) { $this->redirect = ''; $this->redirect .= $this->frontendController->typoLink(array('parameter' => $parameter, 'forceAbsoluteUrl' => true)); - - $this->redirect .= (strpos($this->redirect, '?') === false) ? '?' : '&'; - $this->redirect .= 'redirect_url='.$error->getUrl(); - + if (!$this->frontendUser->isLoggedIn()) { + $this->redirect .= (strpos($this->redirect, '?') === false) ? '?' : '&'; + $this->redirect .= 'redirect_url=' . urlencode($error->getUrl()); + } return true; }