public function execute() { $httpContext = new \Framework\Core\HttpContext(); try { $isInRole = Identity::isUserInRole($httpContext->identity()->username, \Framework\Config\Config::USER_ROLES[0]); if (!Identity::isUserLogged() || !$isInRole) { $root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; header("Location: {$root}", 302); } } catch (\Exception $e) { $root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; header("Location: {$root}", 302); } }
public function execute() { $role = $this->annotationValue; $httpContext = new \Framework\Core\HttpContext(); if (!isset($role) || trim($role) == "" || $role === true) { if (!Identity::isUserLogged()) { $root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; header("Location: {$root}", 302); } } else { try { $isInRole = Identity::isUserInRole($httpContext->identity()->username, $role); if (!Identity::isUserLogged() || !$isInRole) { $root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; header("Location: {$root}", 302); } } catch (\Exception $e) { $root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; header("Location: {$root}", 302); } } }