You are here

private function ServiceController::createRedirectResponse in CAS 2.x

Same name and namespace in other branches
  1. 8 src/Controller/ServiceController.php \Drupal\cas\Controller\ServiceController::createRedirectResponse()

Create a redirect response that sends users somewhere after login.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request.

bool $login_failed: Indicates if the login failed or not.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse The redirect response.

1 call to ServiceController::createRedirectResponse()
ServiceController::handle in src/Controller/ServiceController.php
Main point of communication between CAS server and the Drupal site.

File

src/Controller/ServiceController.php, line 315

Class

ServiceController
Controller used when redirect back from CAS authentication.

Namespace

Drupal\cas\Controller

Code

private function createRedirectResponse(Request $request, $login_failed = FALSE) {

  // If login failed, we may have a failure page to send them to. Don't do it
  // if the request was from a gateway auth attempt though, as the login was
  // optional.
  if ($login_failed && $this->settings
    ->get('error_handling.login_failure_page') && !$request->query
    ->has('from_gateway')) {

    // Remove 'destination' parameter, otherwise Drupal's
    // RedirectResponseSubscriber will send users to that location instead of
    // the failure page.
    $request->query
      ->remove('destination');
    return RedirectResponse::create(Url::fromUserInput($this->settings
      ->get('error_handling.login_failure_page'))
      ->toString());
  }
  else {
    $this->casHelper
      ->handleReturnToParameter($request);
    return RedirectResponse::create($this->urlGenerator
      ->generate('<front>'));
  }
}