Feature #53822
Show nice error page for inaccessible nodes
Status: | New | Start date: | 2013-11-21 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | - | % Done: | 0% |
|
Category: | - | |||
Target version: | - |
Description
When a node is set with accessRoles and if somehow user reach this node and not matching the role then user see a error like "An error occurred while trying to call TYPO3\Neos\Controller\Frontend\NodeController->showAction(). Error for node: Could not convert array to Node object because the node "/sites/xxx/xxx/xxx" does not exist." on a white page.
Currently I am handling this with an Aspect to catch this validation error and redirect user to page which shows access denied message OR just add a flash message. But a better way could be there with the core itself.
/** * Intercepts NodeController->errorAction() * * When a Node is not accessible node is not found error is displayed. * This function will see if certain error number is found and then redirect * user to login form and block call of errorAction(). For other errors errorAction() * is called normally. * * @Flow\Around("method(TYPO3\Neos\Controller\Frontend\NodeController->errorAction())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return void */ public function redirectIfNodeInaccessible(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { /** @var $nodeController \TYPO3\Neos\Controller\Frontend\NodeController */ $nodeController = $joinPoint->getProxy(); /** @var $arguments \TYPO3\Flow\Mvc\Controller\Arguments */ $arguments = ObjectAccess::getProperty($nodeController, 'arguments', TRUE); $nodeInaccessibleError = FALSE; $message = ''; foreach ($arguments->getValidationResults()->getFlattenedErrors() as $propertyPath => $errors) { foreach ($errors as $error) { /** @var $error \TYPO3\Flow\Error\Error */ if ($error->getCode() === 1370502328) { $nodeInaccessibleError = TRUE; $message = $error->getMessage(); break; } } } if ($nodeInaccessibleError) { // redirect user // or add flash message } else { // proceed to executing errorAction normally $joinPoint->getAdviceChain()->proceed($joinPoint); } }