You are here

public function LogoutController::logout in CAS 8

Same name and namespace in other branches
  1. 2.x src/Controller/LogoutController.php \Drupal\cas\Controller\LogoutController::logout()

Logs a user out of Drupal, then redirects them to the CAS server logout.

1 string reference to 'LogoutController::logout'
cas.routing.yml in ./cas.routing.yml
cas.routing.yml

File

src/Controller/LogoutController.php, line 81

Class

LogoutController
Class LogoutController.

Namespace

Drupal\cas\Controller

Code

public function logout() {

  // First log the user out of Drupal.
  user_logout();
  $cas_server_logout_url = $this
    ->getServerLogoutUrl($this->requestStack
    ->getCurrentRequest());
  $this->casHelper
    ->log(LogLevel::DEBUG, "Drupal session terminated; redirecting to CAS server logout at %url", [
    '%url' => $cas_server_logout_url,
  ]);

  // Redirect the user to the CAS server for logging out there as well.
  return new CasRedirectResponse($cas_server_logout_url, 302);
}