check if token exists
194686
public static function check( $token )
    {
        $token_name = 'token';

        if(Session::exists($token_name) && $token == Session::exists($token_name) )
        {
            Session::delete($token_name);
            return true;
        }
        return false;
    }
663016
def get_token(cls, value):
        ""

        # Use try/except because after running for a short time most tokens
        # should already be cached
        try:
            return cls._cache[value]
        except KeyError:
            token = Token(value)
            cls._cache[value] = token
            return token
141806
def user_exists(username,
                token_manager=None,
                app_url=defaults.APP_URL):
    
    headers = token_manager.get_access_token_headers()
    auth_url = environment.get_auth_url(app_url=app_url)
    url = "%s/api/v1/accounts?username=%s" % (auth_url, username)
    response = requests.get(url, headers=headers)

    if response.status_code == 404:
        return False
    elif response.status_code == 200:
        return True
    else:
        raise JutException('Error %s: %s' % (response.status_code, response.text))
1025802
function isRemovedToken(context, token) {
  var removedNodes = context.removedNodes;
  var nodeIdx = removedNodes.length - 1;

  // Find the last removed node which could possibly contain this token.
  while (nodeIdx >= 0 && startOf(removedNodes[nodeIdx]) > startOf(token)) {
    nodeIdx--;
  }

  var node = removedNodes[nodeIdx];

  // This token couldn't be removed if not contained within the removed node.
  if (nodeIdx === -1 || endOf(node) < endOf(token)) {
    return false;
  }

  // Iterate through the tokens contained by the removed node to find a match.
  var tokens = context.ast.tokens;
  var tokenIdx = findTokenIndex(tokens, startOf(node));
  while (endOf(tokens[tokenIdx]) <= endOf(node)) {
    if (token === tokens[tokenIdx]) {
      return true;
    }
    tokenIdx++;
  }

  return false;
}
943495
async function exists(dir) {
  try {
    debug(`checking if ${dir} exists`);
    const s = await stat(dir);

    debug(`${dir} exists`);

    return s.isDirectory();
  }
  catch (err) {
    debug(`${dir} does not exist`);

    return false;
  }
}
1256907
function processToken(token, done) {
    var user = _.find(users, function (item) {
        return item.username === token[claims.username];
    });
    if (!user) {
        user = {
            id          : token[claims.id] || currId++,
            username    : token[claims.username],
            email       : token[claims.email],
            firstName   : token[claims.firstName],
            lastName    : token[claims.lastName]
        };
        var roles = token[claims.role];
        if (!roles) {
            roles = ["guest"];
        } else if (!(roles instanceof Array)) {
            roles = [roles];
        }
        user.roles = roles;
        users.push(user);
    }
    done(null, user);
}
616356
def check_token(self):
        
        try:
            doc = self.doc_ref.get()
        except Exception as e:
            log.error('Token (collection: {}, doc_id: {}) '
                      'could not be retrieved from the backend: {}'
                      .format(self.collection, self.doc_id, str(e)))
            doc = None
        return doc and doc.exists
884814
function isChecked(token) {
    var checked = false;

    if (token.content.indexOf('[x]') === 0 || token.content.indexOf('[X]') === 0) {
        checked = true;
    }

    return checked;
}
42535
function checkIsHttpToken(val) {
  if (typeof val !== 'string' || val.length === 0)
    return false;
  if (!isValidTokenChar(val.charCodeAt(0)))
    return false;
  const len = val.length;
  if (len > 1) {
    if (!isValidTokenChar(val.charCodeAt(1)))
      return false;
    if (len > 2) {
      if (!isValidTokenChar(val.charCodeAt(2)))
        return false;
      if (len > 3) {
        if (!isValidTokenChar(val.charCodeAt(3)))
          return false;
        for (var i = 4; i < len; i++) {
          if (!isValidTokenChar(val.charCodeAt(i)))
            return false;
        }
      }
    }
  }
  return true;
}
626611
def token_name(tokens, expected):
    """"""
    try:
        token = next(iter(tokens))
    except StopIteration:
        return

    if token and token.name == expected:
        return TokenMatch(None, token.value, (token,))
425272
function deleteToken(username, token, done) {
  return tokenExists(username, token, function(existsErr, tokenObj) {
    if (existsErr) {
      return done(existsErr);
    }

    if (!tokenObj) {
      return done(new Error(`token '${token}' not found`));
    }

    return tokenObj.destroy(done);
  });
}
1282897
private function hasToken(array $matchList, string $tokenKey): bool
    {
        return array_key_exists($tokenKey, $matchList) && strlen($matchList[$tokenKey]);
    }
1325905
function hasTokenCredentials() {
		return (cred.token && cred.token.length > 0 && cred.secret && cred.secret.length > 0);
	}
1128029
function isRemovedToken(context, token) {
  var removedNodes = context.removedNodes;
  var nodeIdx = removedNodes.length - 1;

  // Find the last removed node which could possibly contain this token.
  while (nodeIdx >= 0 && removedNodes[nodeIdx].start > token.start) {
    nodeIdx--;
  }

  var node = removedNodes[nodeIdx];

  // This token couldn't be removed if not contained within the removed node.
  if (nodeIdx === -1 || node.end < token.end) {
    return false;
  }

  // Iterate through the tokens contained by the removed node to find a match.
  var tokens = context.ast.tokens;
  var tokenIdx = findTokenIndex(tokens, node.start);
  while (tokens[tokenIdx].end <= node.end) {
    if (token === tokens[tokenIdx]) {
      return true;
    }
    tokenIdx++;
  }

  return false;
}
10455
def look(self):
        """"""
        old_token = next(self)
        result = self.current
        self.push(result)
        self.current = old_token
        return result
685416
public function isSameAs(Token $token)
    {
        $hasNumberWildcard = ($this->hasNumber() && $token->hasNumber());
        if ($hasNumberWildcard && $this->number !== $token->number) {
            return false;
        }
        $hasValueWildcard = ($this->hasValue() && $token->hasValue());
        if ($hasValueWildcard && $this->value !== $token->value) {
            return false;
        }
        $hasLineNumberWildcard = ($this->hasLineNumber() && $token->hasLineNumber());
        if ($hasLineNumberWildcard && $this->lineNumber !== $token->lineNumber) {
            return false;
        }

        return true;
    }
1307669
def _expect_token(lexer, types):
    """"""
    tok = next(lexer)
    if any(isinstance(tok, t) for t in types):
        return tok
    else:
        raise Error("unexpected token: " + str(tok))