Пример #1
0
 /**
  * @return bool
  */
 public static function preProcess()
 {
     if (!parent::preProcess()) {
         return false;
     }
     if (!static::$currentUser->isAuthenticated()) {
         Session::set('security.called_before_login', $_SERVER['REQUEST_URI']);
         static::redirect('Security::login');
         return false;
     } else {
         if (static::$controllerRole == 'anonymous' || static::$currentUser->isInRole(static::$controllerRole)) {
             return true;
         } else {
             return static::forbidden();
         }
     }
 }
Пример #2
0
 /**
  * @return array[]
  */
 public function getGroups()
 {
     if (!Session::get('security.ldap_groups')) {
         $security = Config::get()->security;
         $list = ldap_search($this->conn, $security->user_base_dn, 'objectclass=group');
         $entries = ldap_get_entries($this->conn, $list);
         unset($entries['count']);
         Session::set('security.ldap_groups', array());
         foreach ($entries as $entry) {
             if (isset($entry[$security->groupname_attribute])) {
                 $groupDn = $entry["distinguishedname"][0];
                 if ($groupDn) {
                     Session::set('security.ldap_groups.' . $groupDn, $this->getGroupUsers($groupDn));
                 }
             }
         }
     }
     return Session::get('security.ldap_groups');
 }
 public function currentUser()
 {
     return Session::get('security.current_user') ? $this->getUser(Session::get('security.current_user')) : new $this->userClass('anonymous', new \StdClass());
 }
Пример #4
0
 /**
  * @return bool
  */
 public static function logout()
 {
     Session::stop();
     $logoutAction = isset(Config::get()->security->logoutAction) ? Config::get()->security->logoutAction : 'Application::index';
     return static::redirect($logoutAction);
 }
Пример #5
0
 public function initialize()
 {
     Session::start();
 }