src/lib/db.js
function tokenExists(username, token, done) {
  return getTokenHashes(username, function(getTokensErr, hashes) {
    if (getTokensErr) {
      return done(getTokensErr);
    }

    if (!hashes || !hashes.length) {
      return done(null, false);
    }

    let index = 0;
    let found = false;

    async.until(() => found || (index >= hashes.length), function(next) {
      bcrypt.compare(token, hashes[index++].uuid, function(err, match) {
        found = match;
        return next(err);
      });
    }, (err) => done(err, found ? hashes[index - 1] : undefined));
  });
}
function tokenExists(username, token, done) {
  return getTokenHashes(username, function(getTokensErr, hashes) {
    if (getTokensErr) {
      return done(getTokensErr);
    }

    if (!hashes || !hashes.length) {
      return done(null, false);
    }

    let index = 0;
    let found = false;

    async.until(() => found || (index >= hashes.length), function(next) {
      bcrypt.compare(token, hashes[index++].uuid, function(err, match) {
        found = match;
        return next(err);
      });
    }, (err) => done(err, found ? hashes[index - 1] : undefined));
  });
}
function tokenExists ( username , token , done ) { return getTokenHashes ( username , function ( getTokensErr , hashes ) { if ( getTokensErr ) { return done ( getTokensErr ) ; } if ( ! hashes || ! hashes . length ) { return done ( null , false ) ; } let index = 0 ; let found = false ; async . until ( ( ) => found || ( index >= hashes . length ) , function ( next ) { bcrypt . compare ( token , hashes [ index ++ ] . uuid , function ( err , match ) { found = match ; return next ( err ) ; } ) ; } , ( err ) => done ( err , found ? hashes [ index - 1 ] : undefined ) ) ; } ) ; }
Check if token exists. If found it is returned.

@param {String} token
@param {Function} done - done(err, tokenObj)
Check if token exists . If found it is returned .