You are here

function tokenauth_reset in Token authentication 7

Same name and namespace in other branches
  1. 5 tokenauth.module \tokenauth_reset()
  2. 6.2 tokenauth.inc \tokenauth_reset()
  3. 6 tokenauth.inc \tokenauth_reset()

API function to reset all tokens.

Parameters

$uid: [optional] UID of a specific user to reset. Will default to resetting all users.

$token: [optional] A specific string to use as the token. Defaults to a string generated randomly with user_password().

$update: [optional] If true, will update the user's token entry. Otherwise will insert a new one.

Return value

For a single user, returns token string. For multiple users, returns TRUE.

5 calls to tokenauth_reset()
drush_tokenauth_reset in ./tokenauth.drush.inc
Drush command callback for "tokenauth-reset".
drush_tokenauth_reset_all in ./tokenauth.drush.inc
Drush command callback for "tokenauth-reset-all".
tokenauth_insert in ./tokenauth.inc
API Function to insert new user tokens.
tokenauth_reset_confirm_submit in ./tokenauth.pages.inc
Handler for reset tokens confirmation
tokenauth_user_reset_confirm_submit in ./tokenauth.pages.inc
Handler for reset tokens confirmation
1 string reference to 'tokenauth_reset'
tokenauth_uninstall in ./tokenauth.install
Implements hook_uninstall().

File

./tokenauth.inc, line 20
Provides tokenauth API for Token Authentication module.

Code

function tokenauth_reset($uid = NULL, $token = NULL, $update = TRUE) {
  if (!is_null($uid)) {
    return tokenauth_reset_user($uid, $token, $update);
  }
  else {
    $sql = 'SELECT uid FROM {users} WHERE uid > 0';
    $results = db_query($sql);
    foreach ($results as $row) {
      tokenauth_reset_user($row->uid, $token, $update);
    }
    return TRUE;
  }
}