You are here

function tokenauth_get_token in Token authentication 5

Same name and namespace in other branches
  1. 6.2 tokenauth.inc \tokenauth_get_token()
  2. 6 tokenauth.inc \tokenauth_get_token()
  3. 7 tokenauth.inc \tokenauth_get_token()

API function for retrieving the token for a given user.

Parameters

string $uid : Assumes current user if no user is provided.

Return value

string A token, or FALSE if user has no token.

1 call to tokenauth_get_token()
tokenauth_user_profile_form in ./tokenauth.module
Menu callback. Prints the token and instructions.

File

./tokenauth.module, line 105

Code

function tokenauth_get_token($uid = NULL) {
  if (is_null($uid)) {
    global $user;
    $uid = $user->uid;
  }
  $token = db_result(db_query("SELECT tt.token FROM {tokenauth_tokens} tt WHERE tt.uid = %d", $uid));
  if ($token) {
    return "token={$token}";
  }
  else {
    return FALSE;
  }
}