eZ\Publish\Core\REST\Server\Controller\SessionController::refreshSessionAction PHP Method

refreshSessionAction() public method

Refresh given session.
public refreshSessionAction ( string $sessionId, Request $request ) : UserSession
$sessionId string
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\UserSession
    public function refreshSessionAction($sessionId, Request $request)
    {
        $session = $request->getSession();
        if ($session === null || !$session->isStarted() || $session->getId() != $sessionId || !$this->hasStoredCsrfToken()) {
            $response = $this->authenticator->logout($request);
            $response->setStatusCode(404);
            return $response;
        }
        $this->checkCsrfToken($request);
        return new Values\UserSession($this->repository->getCurrentUser(), $session->getName(), $session->getId(), $request->headers->get('X-CSRF-Token'), false);
    }

Usage Example

Beispiel #1
0
 /**
  * Refresh given session.
  *
  * @param string $sessionId
  *
  * @throws \eZ\Publish\Core\Base\Exceptions\UnauthorizedException If the CSRF token is missing or invalid.
  *
  * @return \eZ\Publish\Core\REST\Server\Values\UserSession
  *
  * @deprecated Deprecated since 6.5. Use SessionController::refreshSessionAction().
  */
 public function refreshSession($sessionId, Request $request)
 {
     @trigger_error(E_USER_DEPRECATED, 'The session actions from the User controller are deprecated since 6.5. Use the SessionController instead.');
     return $this->sessionController->refreshSessionAction($sessionId, $request);
 }