You are here

public function LoginController::login in Shibboleth Authentication 8

Login-- Processes Drupal login, then redirects.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse

1 string reference to 'LoginController::login'
shib_auth.routing.yml in ./shib_auth.routing.yml
shib_auth.routing.yml

File

src/Controller/LoginController.php, line 54

Class

LoginController
Class LogoutController.

Namespace

Drupal\shib_auth\Controller

Code

public function login() {
  if (!empty($this->loginHandler
    ->getShibSession()
    ->getSessionId())) {

    // Check if there is an active drupal login.
    if (\Drupal::currentUser()
      ->isAnonymous()) {

      // Call the shib login function in the login handler class.
      if ($response = $this->loginHandler
        ->shibLogin()) {

        // We need to remove the destination or it will redirect to that
        // rather than where we actually want to go.
        \Drupal::request()->query
          ->remove('destination');
        return $response;
      }
    }
  }

  // Will redirect to ?destination by default.
  return $this
    ->redirect('<front>');
}