You are here

function fboauth_action_deauth in Facebook OAuth (FBOAuth) 7

Same name and namespace in other branches
  1. 6 includes/fboauth.fboauth.inc \fboauth_action_deauth()
  2. 7.2 includes/fboauth.fboauth.inc \fboauth_action_deauth()

Facebook OAuth callback for deauthorizing the site from Facebook.

1 string reference to 'fboauth_action_deauth'
fboauth_fboauth_actions in ./fboauth.module
Implements hook_fboauth_actions().

File

includes/fboauth.fboauth.inc, line 219
Provides functions used during Facebook login processes.

Code

function fboauth_action_deauth($app_id, $access_token) {
  global $user;

  // Deauthorize our application from Facebook.
  $result = fboauth_method_invoke('auth.revokeAuthorization', $access_token);

  // If successful, also remove the uid-fbid pairing.
  if (!is_array($result) && $result) {
    $fbid = fboauth_fbid_load($user->uid);
    fboauth_save($user->uid, NULL);

    // Allow other modules to hook into a deauth event.
    module_invoke_all('fboauth_deauthorize', $user->uid, $fbid);
    drupal_set_message(t('Your account has been disconnected from Facebook.'));
  }
  else {
    drupal_set_message(t('There was an error disconnecting from Facebook. The server returned %message.', array(
      '%message' => $result->error_msg,
    )), 'error');
    watchdog('There was an error disconnecting the user %username from Facebook. The server returned %message.', array(
      '%message' => $result->error_msg,
      '%username' => $user->name,
    ));
  }
}