You are here

function oauth2_login_user_logout in OAuth2 Login 7.2

Same name and namespace in other branches
  1. 7 oauth2_login.module \oauth2_login_user_logout()

Implements hook_user_logout().

File

./oauth2_login.module, line 299
Provides OAuth2 Login functionality.

Code

function oauth2_login_user_logout($account) {

  // If the client and the server are on the same application
  // then no redirection needs to e done.
  $oauth2_server = variable_get('oauth2_login_oauth2_server', '');
  if (empty($oauth2_server)) {
    return;
  }
  $server_host = parse_url($oauth2_server, PHP_URL_HOST);
  $base_host = parse_url($GLOBALS['base_url'], PHP_URL_HOST);
  if ($server_host == $base_host) {
    return;
  }

  // Get the current access_token.
  $token_endpoint = $oauth2_server . '/oauth2/token';
  $client_id = variable_get('oauth2_login_client_id', '');
  $auth_flow = 'server-side';
  $id = md5($token_endpoint . $client_id . $auth_flow);
  $token = oauth2_client_get_token($id);
  drupal_register_shutdown_function('_logout_from_oauth2_server', $token['access_token']);
}