/** * 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; }
/** * 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; }
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); }
/** * 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(); }
/** * 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(); }
/** * @param SessionInterface $session * @param int $userId */ public function logIn(SessionInterface $session, $userId) { $session->migrate(); $session->set('user_id', $userId); }
/** * Migrate session * * @param bool $destroy * @param null $lifetime */ public function migrate($destroy = false, $lifetime = null) { $this->session->migrate($destroy, $lifetime); }
/** * @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); }
/** * @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')); }