You are here

function oauth_common_user_delete in OAuth 1.0 7.4

Same name and namespace in other branches
  1. 7.3 oauth_common.module \oauth_common_user_delete()

Implements hook_user_delete().

File

./oauth_common.module, line 243

Code

function oauth_common_user_delete($account) {

  // Delete all tokens and consumers related to a user
  module_load_include('inc', 'oauth_common');
  $consumer_condition = db_select('oauth_common_provider_consumer', 'c')
    ->condition('uid', $account->uid)
    ->fields('c', array(
    'csid',
  ));
  $token_condition = db_or()
    ->condition('uid', $account->uid)
    ->condition('csid', $consumer_condition, 'IN');
  db_delete('oauth_common_provider_token')
    ->condition('tid', db_select('oauth_common_token', 't')
    ->condition($token_condition)
    ->fields('t', array(
    'tid',
  )), 'IN')
    ->execute();
  db_delete('oauth_common_token')
    ->condition($token_condition)
    ->execute();
  db_delete('oauth_common_consumer')
    ->condition('csid', $consumer_condition, 'IN')
    ->execute();
  db_delete('oauth_common_provider_consumer')
    ->condition('uid', $account->uid)
    ->execute();
}