"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var passport = __importStar(require("passport"));
var passport_local_1 = require("passport-local");
var models_1 = require("./models");
passport.use(new passport_local_1.Strategy({
    usernameField: 'user[email]',
    passwordField: 'user[password]',
}, function (email, password, done) {
    models_1.userModel.findOne({ email: email })
        .then(function (user) {
        if (!user || !user.validatePassword(password)) {
            return done(null, false, { message: 'email or password missing' });
        }
        return done(null, user);
    }).catch(done);
}));
