passportjs错误callback抛出exception

我正在使用MYSQL(具有sequelize)LocalStrategy这是除了当MYSQL抛出exception(只是为了testing,我closuresMYSQL服务器)正在工作。 return done(error)callback抛出exception崩溃的服务器。

这是我的一段代码:

 passport.use(new LocalStrategy({usernameField: 'email', passwordField: 'password'}, function (email, password, done) { db.User.find({where: {email: email}}).done(function (error, user) { if(error) return done(error); if (!user) return done(null, false, {message: 'unknown user'}); //validate password if (user.password != password) { return done(null, false, {message: 'invalid password'}); } //all ok return done(null, user); }); } )); 

而例外:

 TypeError: Property 'next' of object #<Context> is not a function at Context.actions.error 

我究竟做错了什么? 谢谢!

编辑:

  req._passport.instance.authenticate('local', function (err, user, info) { if (err) return validator.emit('exception', err); if (!user) { validator.result.errors.push('Username and password combination not found.'); validator.emit('response'); } else { req.login(user, function (error) { if (error) return validator.emit('exception', error); validator.emit('response'); }); } })(req, res); 

好吧,我傻了,最后我错过了next

 req._passport.instance.authenticate('local', function (err, user, info) { ..... })(req, res, next);