/** * Redirects to the Neos backend on the given site, passing a one-time login token * * @param Site $site * @return void */ public function switchSiteAction($site) { $token = Algorithms::generateRandomToken(32); $this->loginTokenCache->set($token, $this->currentSession->getId()); $siteUri = $this->linkingService->createSiteUri($this->controllerContext, $site); $loginUri = $this->controllerContext->getUriBuilder()->reset()->uriFor('tokenLogin', ['token' => $token], 'Login', 'TYPO3.Neos'); $this->redirectToUri($siteUri . $loginUri); }
/** * Redirects to the Neos backend on the given hostname, passing a one-time login token * * @param string $hostname * @return void */ public function switchSiteAction($hostname) { $token = Algorithms::generateRandomToken(32); $this->loginTokenCache->set($token, $this->currentSession->getId()); $requestUri = $this->controllerContext->getRequest()->getHttpRequest()->getUri(); $baseUri = $this->controllerContext->getRequest()->getHttpRequest()->getBaseUri(); $uri = $this->controllerContext->getUriBuilder()->reset()->uriFor('tokenLogin', ['token' => $token], 'Login', 'TYPO3.Neos'); $uri = sprintf('%s://%s%s%s', $requestUri->getScheme(), $hostname, rtrim($baseUri->getPath(), '/'), $uri); $this->redirectToUri($uri); }
/** * Returns the specified session. If no session with the given identifier exists, * NULL is returned. * * @param string $sessionIdentifier The session identifier * @return \TYPO3\Flow\Session\Session * @api */ public function getSession($sessionIdentifier) { if ($this->currentSession !== NULL && $this->currentSession->isStarted() && $this->currentSession->getId() === $sessionIdentifier) { return $this->currentSession; } if (isset($this->remoteSessions[$sessionIdentifier])) { return $this->remoteSessions[$sessionIdentifier]; } if ($this->metaDataCache->has($sessionIdentifier)) { $sessionInfo = $this->metaDataCache->get($sessionIdentifier); $this->remoteSessions[$sessionIdentifier] = new Session($sessionIdentifier, $sessionInfo['storageIdentifier'], $sessionInfo['lastActivityTimestamp'], $sessionInfo['tags']); return $this->remoteSessions[$sessionIdentifier]; } }
/** * @param \Peytz\Vote\Domain\Model\Vote $newVote * @return void */ public function registerAction(Vote $newVote) { if (!$this->session->isStarted()) { $this->session->start(); } /** @var \Peytz\Vote\Domain\Model\Vote $vote */ if ($vote = $this->voteRepository->findOneBySession($this->session->getId())) { $vote->setDate(new \DateTime()); $vote->setValue($newVote->getValue()); $this->voteRepository->update($vote); } else { $newVote->setDate(new \DateTime()); $newVote->setSession($this->session->getId()); $this->voteRepository->add($newVote); } $this->session->putData('hasVoted', true); $this->addFlashMessage('Vote registered.'); $this->redirect('index'); }
/** * @Flow\Session(autoStart = true) * @return string */ public function sessionStartAction() { return 'this action started session ' . $this->session->getId(); }