You are here

function cas_server_logout in CAS 7

Same name and namespace in other branches
  1. 5.4 cas_server.module \cas_server_logout()
  2. 5.3 cas_server.module \cas_server_logout()
  3. 6.3 cas_server.module \cas_server_logout()
  4. 6.2 cas_server.module \cas_server_logout()

Menu callback; triggers a CAS logout.

1 string reference to 'cas_server_logout'
cas_server_menu in ./cas_server.module
Implementation of hook_menu

File

./cas_server.module, line 315
Provides a protocol compliant version of CAS server 2.x

Code

function cas_server_logout() {

  // Check service against whitelist
  if (isset($_GET['service']) && !_cas_server_check_service_whitelist($_GET['service'])) {
    return variable_get('cas_server_whitelist_failure', t('You do not have permission to login to CAS from this service.'));
  }
  global $user;

  // Due to the order of sessions being destroyed on a client site vs CAS server,
  // there is a workflow that would allow the user's session to not exist at this point.
  // Skip triggering user logout related processes if there is not a valid user in session.
  if (user_is_logged_in()) {

    // Log the successful logout process.
    watchdog('user', 'Session closed for %name.', array(
      '%name' => format_username($user),
    ));

    // Tell modules about the logout.
    module_invoke_all('user_logout', $user);
  }

  // Destroy the current session, and reset $user to the anonymous user.
  session_destroy();
  $output = '<p>' . t('You have been logged out successfully.') . '</p>';
  if (isset($_REQUEST['url'])) {
    $output .= '<p>' . l(t('Continue'), $_REQUEST['url']) . '</p>';
  }
  return $output;
}