public function testLogout() { $handler = new SessionLogoutHandler(); $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request'); $response = new Response(); $session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Session', array(), array(), '', false); $request->expects($this->once())->method('getSession')->will($this->returnValue($session)); $session->expects($this->once())->method('invalidate'); $handler->logout($request, $response, $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface')); }
public function closeAccount(Response $response) { $user = $this->securityContext->getToken()->getUser(); $user->setEnabled(false); $this->userManager->updateUser($user); $cookieHandler = new CookieClearingLogoutHandler($this->request->cookies->all()); $cookieHandler->logout($this->request, $response, $this->securityContext->getToken()); $sessionHandler = new SessionLogoutHandler(); $sessionHandler->logout($this->request, $response, $this->securityContext->getToken()); $this->securityContext->setToken(null); }
/** * {@inheritdoc} * * PHP 5.4 versions prior to 5.4.11 suffer from a bug in SessionHandler * (see https://bugs.php.net/bug.php?id=63379). The only workaround for * those versions is to avoid session invalidation (see * https://github.com/symfony/symfony/issues/5868). Here the workaround * will be applied only if the PHP version is buggy (as opposed to a * permanent "invalidate_session: false" in the firewall configuration). * * @param Request $request * @param Response $response * @param TokenInterface $token */ public function logout(Request $request, Response $response, TokenInterface $token) { if (version_compare(phpversion(), '5.4.11', '>=')) { parent::logout($request, $response, $token); } }