Beispiel #1
0
 public function startup()
 {
     if ($this->UserLogin->loggedin()) {
         $this->UserLogin->User->UserGroup = $this->controller->UserGroup->findById($this->UserLogin->User->user_group_id);
         $this->Permissions = $this->UserLogin->User->UserGroup->Permissions;
     }
     $this->controller->data->set(get_class($this), $this);
     return parent::startup();
 }
Beispiel #2
0
 public function startup()
 {
     $this->headers = new Hash(array('Reply-To' => Registry::get('AdminEmail'), 'From' => Registry::get('AdminEmail')));
     return parent::startup();
 }
Beispiel #3
0
 public function startup()
 {
     $this->controller->addModel('LogEntry');
     return parent::startup();
 }
Beispiel #4
0
 public function startup()
 {
     $this->controller->addModel('User');
     // check login from session
     if ($userId = $this->Session->get($this->sessionUserIdName)) {
         Log::write(Log::VERBOSE, get_class($this) . ': found user id in session: ' . $userId);
         $this->User = $this->controller->User->findById($userId);
         // check login for permanent cookie value
     } elseif ($this->permanent && $this->controller->User->hasField('permanent_key') && ($permanentCookieValue = $this->Cookie->get($this->permanentCookiename))) {
         if ($this->validPermanentKey($permanentCookieValue)) {
             Log::write(Log::VERBOSE, get_class($this) . ': found permanent cookie: ' . $permanentCookieValue);
             $this->User = $this->controller->User->findByPermanentKey($permanentCookieValue);
         }
     }
     // check for http auth login
     if ($this->httpAuth && !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
         try {
             $this->User = $this->login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
         } catch (UserLoginFailedException $e) {
             $this->User = false;
         }
     }
     if ($this->loggedin()) {
         // drop user if his ip does not match the ip when he logged in
         if ($this->checkIp && $this->User->hasField('ip') && $this->User->ip !== ip2long($this->controller->request->host)) {
             Log::write(Log::VERBOSE, get_class($this) . ': invalid ip match, logging out');
             $this->logout();
         } elseif ($this->User->hasBehavior('Flagable') && $this->User->hasFlag(UserFlag::BLOCKED)) {
             Log::write(Log::VERBOSE, get_class($this) . ': user dropped because he was logged in and blocked.');
             $this->logout();
         } else {
             Log::write(Log::VERBOSE, get_class($this) . ': Logging in as: ' . $this->User->get($this->usernameField));
             // refresh user in session
             $this->Session->set($this->sessionUserIdName, $this->User->get('id'));
             // 	set Me to the current user that is logged in
             $this->controller->data->set('Me', $this->User);
             // refresh permanent cookie
             if ($this->permanent && !$this->User->isEmpty('permanent_key')) {
                 $this->Cookie->set($this->permanentCookiename, $this->User->get('permanent_key'));
             }
             if ($this->updateOnAction) {
                 $this->User->save(false);
             }
         }
     }
     return parent::startup();
 }