Ejemplo n.º 1
0
 public function _index()
 {
     $this->assign('title', 'Home');
     $this->flash('info', "Welcome " . Core\Auth::user()->name . " !");
     $this->assign('subtitle', 'Please select a module to manage.');
     $this->renderView('views/admin.index');
 }
Ejemplo n.º 2
0
 /**
  * Allows access only to logged users that have a level equal to or less than provided role. If permission is not granted, it will send a JSON error object.
  * <p><b>Note that while it's doing all login/auth/redirection work automatically, you still have to create the corresponding user table in your database in addition to provide the login module into orion's module directory.</b></p>
  * @see OrionAuth
  *      MainConfig
  *      LoginModule
  * @param string $slug the role identifier (ie: 'administrator', 'member', etc.). See your configuration file for a liste of roles and their permission level.
  */
 public function allow($slug)
 {
     try {
         if (!Core\Auth::login(true)) {
             $this->sendError(self::E_LOGIN_DISALLOW);
         }
         if (!Core\Auth::allow($slug)) {
             // this exception prevents any redirection defect or hack
             $this->sendError(self::E_LOGIN_DISALLOW);
         }
     } catch (Core\Exception $e) {
         throw $e;
     }
 }
Ejemplo n.º 3
0
 public function _login()
 {
     try {
         Core\Auth::login();
         if (isset($_SESSION['orion_auth_target']) && $_SESSION['orion_auth_target'] != Core\Context::genModuleURL($this->name)) {
             $target = $_SESSION['orion_auth_target'];
             unset($_SESSION['orion_auth_target']);
             Core\Context::redirect($target);
         } else {
             Core\Context::redirect(Core\Context::genURL(\Orion::config()->get('DEFAULT_LOGGED_PAGE')));
         }
     } catch (Core\Exception $e) {
         $this->assign('info', $e->getMessage());
         $this->assign('type', 'error');
     }
     $this->renderView('views/login');
 }
Ejemplo n.º 4
0
 /**
  * Get important context data as an array (useful for template hydratation)
  */
 public function getDataArray()
 {
     $array = array();
     try {
         $array['module'] = array();
         $array['module']['name'] = \Orion::module()->getName();
         $array['module']['path'] = \Orion\Core\Context::getModulePath();
         $array['module']['url'] = \Orion\Core\Context::getModuleURL(\Orion::module()->getName());
         $array['module']['uri'] = \Orion\Core\Context::getModuleURI();
         $array['module']['fulluri'] = \Orion\Core\Context::getFullURI();
         $array['template'] = array();
         $array['template']['name'] = \Orion::module()->getTemplate();
         $array['template']['path'] = \Orion\Core\Context::getTemplatePath(\Orion::module()->getTemplate());
         $array['template']['abspath'] = \Orion\Core\Context::getTemplateAbsolutePath(\Orion::module()->getTemplate());
         if (\Orion::config()->defined(strtoupper(\Orion::getMode()) . '_MENU')) {
             $array['menu'] = \Orion::config()->get(strtoupper(\Orion::getMode()) . '_MENU');
         }
         $array['title'] = \Orion::config()->get('SITE_NAME');
         $array['description'] = \Orion::config()->get('SITE_DESC');
         $array['author'] = \Orion::config()->get('SITE_AUTHOR');
         $array['baseurl'] = \Orion::config()->get('BASE_URL');
         $array['mode'] = \Orion::getMode();
         $array['logged'] = \Orion\Core\Auth::logged() ? 'yes' : 'no';
         if (\Orion\Core\Auth::user() != null) {
             $array['user'] = array();
             $array['user']['login'] = \Orion\Core\Auth::user()->login;
             $array['user']['hasadmin'] = \Orion\Core\Auth::user()->is('moderator', true);
         }
     } catch (Exception $e) {
         $array['error'] = 'Unable to retreive all data.';
     }
     return $array;
 }