Ejemplo n.º 1
0
 /**
  * @Route ("/logout")
  *
  * @return string
  */
 public function logout()
 {
     if (Session::isStarted()) {
         ChatIntegrationService::instance()->deleteChatSession(Session::getSessionId());
         Session::destroy();
     }
     return 'redirect: /';
 }
Ejemplo n.º 2
0
 /**
  * Checks the users current session status
  * Does a remember me login
  * @return void
  */
 public function init()
 {
     $app = Application::instance();
     $authService = AuthenticationService::instance();
     // If the session hasnt started, or the data is not valid (result from php clearing the session data), check the Remember me cookie
     if (!Session::isStarted() || !Session::getCredentials()->isValid()) {
         $userId = $authService->getRememberMe();
         if ($userId !== false) {
             $userManager = UserService::instance();
             $user = $userManager->getUserById($userId);
             if (!empty($user)) {
                 Session::start(Session::START_NOCOOKIE);
                 $credentials = $authService->getUserCredentials($user, 'rememberme');
                 Session::updateCredentials($credentials);
                 ChatIntegrationService::instance()->setChatSession($credentials, Session::getSessionId());
                 $authService->setRememberMe($user);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Check if a user has been flagged for updates, and refreshes the session credentials
  * @throws Exception
  */
 public function init()
 {
     $app = Application::instance();
     // Check if the users session has been flagged for update
     if (Session::isStarted()) {
         $userId = Session::getCredentials()->getUserId();
         $lastUpdate = $this->isUserFlaggedForUpdate($userId);
         if (!empty($userId) && $lastUpdate !== false) {
             $this->clearUserUpdateFlag($userId, $lastUpdate);
             $userManager = UserService::instance();
             $user = $userManager->getUserById($userId);
             if (!empty($user)) {
                 // Check the user status
                 if (strcasecmp($user['userStatus'], 'Active') !== 0) {
                     throw new Exception(sprintf('User status not active. Status: %s', $user['userStatus']));
                 }
                 $credentials = $this->getUserCredentials($user, 'session');
                 Session::updateCredentials($credentials);
                 ChatIntegrationService::instance()->setChatSession($credentials, Session::getSessionId());
             }
         }
     }
 }