Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Unhandled rejection Error: Invalid value IncomingMessage {
- // thousands of lines including response, request...
- const passport = require("passport");
- const session = require("../session");
- const flash = require("connect-flash");
- const passportLocal = require("passport-local");
- const LocalStrategy = passportLocal.Strategy;
- const CompanyController = require(`${process.cwd()}/server/controllers/api/v1/company.controller`);
- module.exports = (app) => {
- app.use(session);
- app.use(passport.initialize());
- app.use(passport.session());
- app.use(flash());
- passport.use("local-login", new LocalStrategy({
- usernameField: "email",
- passwordField: "password",
- passReqToCallback: true,
- }, (username, password, done) => {
- CompanyController.findByEmail(username).then((err, user) => {
- if (err) {
- console.log("err");
- return done(err);
- }
- if (!user) {
- console.log("err us");
- return done(null, false);
- }
- if (!user.verifyPassword(password)) {
- console.log("err pw");
- return done(null, false);
- }
- return done(null, user);
- });
- }));
- passport.serializeUser((user, done) => {
- done(null, user);
- });
- passport.deserializeUser((id, done) => {
- done(null, id);
- });
- // passport.use(new LocalStrategy((username, password, done) => {
- // if (username === expectedUser.username && password === expectedUser.password) {
- // return done(null, { username: "username", password: "password" });
- // } else {
- // return done(null, false, { message: "Incorrect credentials" });
- // }
- // }));
- };
- const Company = require(`${process.cwd()}/server/models`).company;
- const companyController = {
- findById: id => Company.findById(id),
- findByEmail: email => Company.findAll({
- where: {
- email: email,
- },
- }),
- };
- module.exports = companyController;
Add Comment
Please, Sign In to add comment