Пример #1
0
 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);
     }
 }
Пример #2
0
 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);
         }
     }
 }