lib/models/users.js
function findByCredentials(username, password, cb) {
  crypto.encode(password, function(err, encoded) {
    if(err) { return cb(err); }

    db.getClient(function(err, client, done) {
      client.query(SELECT_CREDENTIALS, [username, encoded], function(err, r) {
        var result = r && r.rows[0];
        if(!err && !result) { err = new exceptions.AuthenticationFailed(); }
        if(err) {
          cb(err);
          done(err);
        } else {
          cb(null, result);
          done();
        }
      });
    });
  });
}
function findByCredentials(username, password, cb) {
  crypto.encode(password, function(err, encoded) {
    if(err) { return cb(err); }

    db.getClient(function(err, client, done) {
      client.query(SELECT_CREDENTIALS, [username, encoded], function(err, r) {
        var result = r && r.rows[0];
        if(!err && !result) { err = new exceptions.AuthenticationFailed(); }
        if(err) {
          cb(err);
          done(err);
        } else {
          cb(null, result);
          done();
        }
      });
    });
  });
}
function findByCredentials ( username , password , cb ) { crypto . encode ( password , function ( err , encoded ) { if ( err ) { return cb ( err ) ; } db . getClient ( function ( err , client , done ) { client . query ( SELECT_CREDENTIALS , [ username , encoded ] , function ( err , r ) { var result = r && r . rows [ 0 ] ; if ( ! err && ! result ) { err = new exceptions . AuthenticationFailed ( ) ; } if ( err ) { cb ( err ) ; done ( err ) ; } else { cb ( null , result ) ; done ( ) ; } } ) ; } ) ; } ) ; }
Finds a user by `username` and `password`

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

@param {String} username
@param {String} password
@param {Function} cb
Finds a user by username and password