public function execute() { $role = $this->annotationValue; $httpContext = new \Framework\Core\HttpContext(); if (Identity::isUserLogged()) { $root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['SCRIPT_NAME']; header("Location: {$root}", 302); } }
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); } } }
<div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-9" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="navbar-collapse collapse" id="bs-example-navbar-collapse-9" aria-expanded="false"> <?php if (!\Framework\Core\Identity::isUserLogged()) { ?> <ul class="nav navbar-nav navbar-right"> <li><a href="<?php echo \Framework\Helpers\Helpers::url() . 'login'; ?> " class="hvr-underline-reveal"><span class="glyphicon glyphicon-log-in"></span> Login</a></li> <li><a href="<?php echo \Framework\Helpers\Helpers::url() . 'register'; ?> " class="hvr-underline-reveal"><span class="glyphicon glyphicon-registration-mark"></span> Register</a></li> </ul> <?php } else { ?> <ul class="nav navbar-nav">