You are here

function oauth2_server_delete_user_tokens in OAuth2 Server 7

Delete a user's tokens.

Parameters

int $uid: The user ID.

2 calls to oauth2_server_delete_user_tokens()
oauth2_server_user_delete in ./oauth2_server.module
Implements hook_user_delete().
oauth2_server_user_update in ./oauth2_server.module
Implements hook_user_update().

File

./oauth2_server.module, line 143
Provides OAuth2 server functionality.

Code

function oauth2_server_delete_user_tokens($uid) {
  $query = new EntityFieldQuery();
  $query
    ->entityCondition('entity_type', 'oauth2_server_token');
  $query
    ->propertyCondition('uid', $uid);
  $result = $query
    ->execute();
  if (!empty($result['oauth2_server_token'])) {
    $token_ids = array_keys($result['oauth2_server_token']);
    entity_delete_multiple('oauth2_server_token', $token_ids);
  }
}