protected function processNotAuthorized()
    {
        $loginPage = $this->currentSite->getLoginPage();
        $notAuthorized = $this->currentSite->getNotAuthorizedPage();
        $returnToUrl = urlencode($this->request->getServer('REQUEST_URI'));
        $newResponse = new Response();
        $newResponse->setStatusCode('302');

        if (!$this->userService->hasIdentity()) {
            $newResponse->getHeaders()
                ->addHeaderLine(
                    'Location: ' . $loginPage . '?redirect=' . $returnToUrl
                );
        } else {
            $newResponse->getHeaders()
                ->addHeaderLine(
                    'Location: ' . $notAuthorized
                );
        }

        return $newResponse;
    }