All files / strategies/local/db/rethinkdbdash verify.js

100% Statements 12/12
100% Branches 5/5
100% Functions 4/4
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 215x 5x         4x 1x   3x 3x 3x 1x 2x 1x   1x   1x    
export default function verify(email, password, done) {
  this.db.users
    .filter(this.db.r.row('emails').contains({ address: email }))
    .limit(1)
    .run()
    .then(users => {
      if (!users.length)
        return done(null, false, "Invalid email");
 
      const user = users[0];
      this.comparePassword(password, user.password, (err, match) => {
        if (err)
          done(err);
        else if (match)
          done(null, user);
        else
          done(null, false, "Invalid password");
      });
    }).catch(err => done(err));
}