apollo-passport-local-strategy
Version:
Local strategy using email address and hashed, bcrypted password
29 lines (24 loc) • 902 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = verify;
function verify(email, password, done) {
var _this = this;
this.db.fetchUserByEmail(email).then(function (user) {
if (!user) return done(null, false, "Invalid email");
var storedPassword = user && user.services && user.services.password && user.services.password.bcrypt;
if (!storedPassword) return done(null, false, "No password set");
if (!user.verified) {
if (user.resetPassToken) {
return done(null, false, "Reset password is in progress");
}
return done(null, false, "Account not verified");
}
_this.comparePassword(password, storedPassword, function (err, match) {
if (err) done(err);else if (match) done(null, user);else done(null, false, "Invalid password");
});
}).catch(function (err) {
return done(err);
});
}