/** * Logs a user in if a session identifier is available under the given token in the token cache. * * @param string $token * @return void */ public function tokenLoginAction($token) { $newSessionId = $this->loginTokenCache->get($token); $this->loginTokenCache->remove($token); if ($newSessionId === false) { $this->systemLogger->log(sprintf('Token-based login failed, non-existing or expired token %s', $token), LOG_WARNING); $this->redirect('index'); } $this->systemLogger->log(sprintf('Token-based login succeeded, token %s', $token), LOG_DEBUG); $newSession = $this->sessionManager->getSession($newSessionId); if ($newSession->canBeResumed()) { $newSession->resume(); } if ($newSession->isStarted()) { $newSession->putData('lastVisitedNode', null); } else { $this->systemLogger->log(sprintf('Failed resuming or starting session %s which was referred to in the login token %s.', $newSessionId, $token), LOG_ERR); } $this->replaceSessionCookie($newSessionId); $this->redirect('index', 'Backend\\Backend'); }
/** * @test */ public function removeCallsBackend() { $cacheIdentifier = 'someCacheIdentifier'; $backend = $this->prepareDefaultBackend(); $backend->expects($this->once())->method('remove')->with($this->equalTo($cacheIdentifier))->will($this->returnValue(true)); $cache = new StringFrontend('StringFrontend', $backend); $this->assertTrue($cache->remove($cacheIdentifier), 'remove() did not return TRUE'); }