lundi 30 mars 2015

Object #

I working through the Lynda.com course on the MEAN stack and this error keeps occurring. I'm not real sure where to look. I have already scoured through numerous Google pages looking for anything that may give me a clue


This is where I call findUser.



module.exports = function() {
var passport = require('passport');
var passportLocal = require('passport-local');
var userService = require('../services/user-service');

passport.use(new passportLocal.Strategy({usernameField: 'email'}, function(email, password, next) {
userService.findUser(email, function(err, user) {
if (err) {
return next(err);
}
if (!user || user.password !== password) {
return next(null, null);
}
next(null, user);
});
}));

passport.serializeUser(function(user, next) {
next(null, user.email);
});

passport.deserializeUser(function(email, next) {
userService.findUser(email, function(err, user) {
next(err, user);
});
});
};


This is the error that I get when trying to "login" with user information verified in the database.



TypeError: Object #<Object> has no method 'findUser'
at Strategy.module.exports [as _verify] (/home/ubuntu/workspace/auth/passport-config.js:7:17)
at Strategy.authenticate (/home/ubuntu/workspace/node_modules/passport-local/lib/strategy.js:90:12)
at attempt (/home/ubuntu/workspace/node_modules/passport/lib/middleware/authenticate.js:341:16)
at authenticate (/home/ubuntu/workspace/node_modules/passport/lib/middleware/authenticate.js:342:7)
at Layer.handle [as handle_request] (/home/ubuntu/workspace/node_modules/express/lib/router/layer.js:82:5)
at next (/home/ubuntu/workspace/node_modules/express/lib/router/route.js:110:13)
at Route.dispatch (/home/ubuntu/workspace/node_modules/express/lib/router/route.js:91:3)
at Layer.handle [as handle_request] (/home/ubuntu/workspace/node_modules/express/lib/router/layer.js:82:5)
at proto.handle.c (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:267:22)
at Function.proto.process_params (/home/ubuntu/workspace/node_modules/express/lib/router/index.js:321:12)

Aucun commentaire:

Enregistrer un commentaire