You are here

function tokenauth_user in Token authentication 5

Same name and namespace in other branches
  1. 6.2 tokenauth.module \tokenauth_user()
  2. 6 tokenauth.module \tokenauth_user()

Implementation of hook_user(). Boring code to change tokens. No UI yet.

File

./tokenauth.module, line 279

Code

function tokenauth_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'update':
      if (isset($account->tokenauth_token)) {
        $sql = "UPDATE {tokenauth_tokens} SET token = '%s' WHERE uid = %d";
        db_query($sql, $account->tokenauth_token, $account->uid);
      }
      break;
    case 'insert':
      $sql = "INSERT INTO {tokenauth_tokens} (uid, token) VALUES (%d, '%s')";
      db_query($sql, $account->uid, user_password());
      break;
    case 'delete':
      $sql = 'DELETE FROM {tokenauth_tokens} WHERE uid = %d';
      db_query($sql, $account->uid);
  }
}