Ejemplo n.º 1
0
 function init($options)
 {
     parent::init($options);
     // run Phalcon Eye to get session from database
     require_once ROOT_PATH . "/app/engine/Config.php";
     require_once ROOT_PATH . "/app/engine/Exception.php";
     require_once ROOT_PATH . "/app/engine/ApplicationInitialization.php";
     require_once ROOT_PATH . "/app/engine/Application.php";
     $application = new \Engine\Application();
     $application->run('session');
     $identity = Phalcon\DI::getDefault()->get('session')->get('identity');
     $viewer = \User\Model\User::findFirstById($identity);
     if (!$viewer || !$viewer->isAdmin()) {
         die('Access not allowed');
     }
 }
Ejemplo n.º 2
0
 /**
  * Get some user.
  *
  * @param int $id User identity.
  *
  * @return UserModel
  */
 public function get($id)
 {
     return UserModel::findFirstById($id);
 }