示例#1
0
 /**
  * Log out the currently logged in user.
  *
  * @return boolean
  */
 public function revokeSession()
 {
     $this->flashLogger->info(Trans::__('You have been logged out.'));
     // Remove all auth tokens when logging off a user
     if ($sessionAuth = $this->session->get('authentication')) {
         $this->repositoryAuthtoken->deleteTokens($sessionAuth->getUser()->getUsername());
     }
     $this->session->remove('authentication');
     $this->session->migrate(true);
     return false;
 }
示例#2
0
 /**
  * Log out the currently logged in user.
  *
  * @return boolean
  */
 public function revokeSession()
 {
     try {
         // Only show this flash if there are users in the system.
         // Not when we're about to get redirected to the "first users" screen.
         if ($this->repositoryUsers->hasUsers()) {
             $this->flashLogger->info(Trans::__('You have been logged out.'));
         }
     } catch (TableNotFoundException $e) {
         // If we have no table, then we definitely have no users
     }
     // Remove all auth tokens when logging off a user
     if ($sessionAuth = $this->session->get('authentication')) {
         $this->repositoryAuthtoken->deleteTokens($sessionAuth->getUser()->getUsername());
     }
     $this->session->remove('authentication');
     $this->session->migrate(true);
     return false;
 }
示例#3
0
 public function testMigrateDestroy()
 {
     $this->session->set('migrate', 333);
     $this->session->migrate(true);
     $this->assertEquals(333, $this->session->get('migrate'));
 }
 /**
  * Update the session with the given ID.
  *
  * @param  string  $id
  * @return void
  */
 protected function updateSession($id)
 {
     $this->session->set($this->getName(), $id);
     $this->session->migrate(true);
 }
示例#5
0
 /**
  * Log an user into the application.
  *
  * @param UserInterface $user
  * @return Response
  */
 public function login(UserInterface $user)
 {
     $this->session->migrate();
     $this->setUser($user);
     return $this->events->dispatch(AuthEvents::LOGIN, new LoginEvent($user))->getResponse();
 }
示例#6
0
文件: ElggSession.php 项目: elgg/elgg
 /**
  * Migrates the session to a new session id while maintaining session attributes
  *
  * @param boolean $destroy Whether to delete the session or let gc handle clean up
  * @return boolean
  * @since 1.9
  */
 public function migrate($destroy = false)
 {
     return $this->storage->migrate($destroy);
 }
 /**
  * Migrates the current session to a new session id while maintaining all
  * session attributes.
  */
 public function migrate()
 {
     $this->session->migrate();
 }
示例#8
0
 /**
  * @param SessionInterface $session
  * @param int $userId
  */
 public function logIn(SessionInterface $session, $userId)
 {
     $session->migrate();
     $session->set('user_id', $userId);
 }
示例#9
0
 /**
  * Migrate session
  *
  * @param bool $destroy
  * @param null $lifetime
  */
 public function migrate($destroy = false, $lifetime = null)
 {
     $this->session->migrate($destroy, $lifetime);
 }
示例#10
0
文件: Login.php 项目: brainexe/core
 /**
  * @param SessionInterface $session
  * @param AuthenticationDataVO $authenticationVo
  * @param UserVO $userVo
  * @return AuthenticateUserEvent
  */
 private function handleLogin(SessionInterface $session, AuthenticationDataVO $authenticationVo, UserVO $userVo)
 {
     $event = new AuthenticateUserEvent($authenticationVo, AuthenticateUserEvent::CHECK);
     $this->dispatchEvent($event);
     $session->set('user_id', $userVo->id);
     // renew session-id to prevent session fixation
     $session->migrate();
     $event = new AuthenticateUserEvent($authenticationVo, AuthenticateUserEvent::AUTHENTICATED);
     $this->dispatchEvent($event);
 }
示例#11
0
 /**
  * @param SessionInterface $session
  * @param int $userId
  */
 public function logIn(SessionInterface $session, $userId)
 {
     $session->migrate();
     $session->set('user_id', $userId);
     $session->set('sudo_expiry', new DateTime('+30 minutes'));
 }