Exemplo n.º 1
0
Arquivo: Auth.php Projeto: jankal/mvc
 /**
  * {@inheritDoc}
  *
  * @todo if logged in
  * @todo set user in config!!!
  */
 public function run(array $args, $required = true)
 {
     $user = new \Authentication\User($args['session'], \DI::prepare("\\Model\\" . \app::get("user")));
     $loggedIn = $user->isAuthenticated();
     // if loggedin
     if ($loggedIn) {
         $this->assignTplVar("loggedIn", true);
         $this->assignTplVar("user", $user);
         return true;
     } elseif (!$loggedIn && $required) {
         $this->error("Not authorized to access this page!");
         return false;
     } else {
         $this->assignTplVar("loggedIn", false);
         return true;
     }
     return false;
 }