lib/models/tokens.js
function findUserFromToken(token, cb) {
  var q = "SELECT * FROM users " +
    "JOIN tokens t ON t.token = $1 " +
    "JOIN users u ON u.id = t.user_id";

  db.getClient(function(err, client, done) {
    client.query(q, [token], function(err, r) {
      var result = r && r.rows[0];
      if(!result && !err) { err = new exceptions.NotFound(); }
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, result);
        done();
      }
    });
  });
}
function findUserFromToken(token, cb) {
  var q = "SELECT * FROM users " +
    "JOIN tokens t ON t.token = $1 " +
    "JOIN users u ON u.id = t.user_id";

  db.getClient(function(err, client, done) {
    client.query(q, [token], function(err, r) {
      var result = r && r.rows[0];
      if(!result && !err) { err = new exceptions.NotFound(); }
      if(err) {
        cb(err);
        done(err);
      } else {
        cb(null, result);
        done();
      }
    });
  });
}
function findUserFromToken ( token , cb ) { var q = "SELECT * FROM users " + "JOIN tokens t ON t.token = $1 " + "JOIN users u ON u.id = t.user_id" ; db . getClient ( function ( err , client , done ) { client . query ( q , [ token ] , function ( err , r ) { var result = r && r . rows [ 0 ] ; if ( ! result && ! err ) { err = new exceptions . NotFound ( ) ; } if ( err ) { cb ( err ) ; done ( err ) ; } else { cb ( null , result ) ; done ( ) ; } } ) ; } ) ; }
Finds associated user with the token matching `token`

`cb` is passed with the matching user or exceptions.NotFound

@param {String} token
@param {Function} cb
Finds associated user with the token matching token