public function beforeExecuteRoute(Dispatcher $dispatcher)
    {
        $controllerName = $dispatcher->getControllerName();

        // Only check permissions on private controllers
        if ($this->acl->isPrivate($controllerName)) {

            // Get the current identity
            $identity = $this->auth->getIdentity();

            // If there is no identity available the user is redirected to index/index
            if (!is_array($identity)) {

                $this->flash->notice('You don\'t have access to this module: private');

                $dispatcher->forward([
                    'namespace' => 'Modules\Frontend\Controllers',
                    'controller' => 'index',
                    'action' => 'error',
                ]);
                return false;
            }

            // Check if the user have permission to the current option
            $actionName = $dispatcher->getActionName();
            if (!$this->acl->isAllowed($identity['profile'], $controllerName, $actionName)) {

                $this->flash->notice('You don\'t have access to this module: ' . $controllerName . ':' . $actionName);

                if ($this->acl->isAllowed($identity['profile'], $controllerName, 'index')) {
                    $dispatcher->forward([
                        'namespace' => 'Modules\Frontend\Controllers',
                        'controller' => $controllerName,
                        'action' => 'error'
                    ]);
                } else {
                    $dispatcher->forward([
                        'namespace' => 'Modules\Frontend\Controllers',
                        'controller' => 'index',
                        'action' => 'error'
                    ]);
                }

                return false;
            }
        }
    }