node.js - passportjs error callback throwing exception -


i'm using localstrategy mysql(with sequelize) working except when mysql throws exception (just test, shut down mysql server). return done(error) callback throwing exception crashing server.

here piece of code:

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);         });     } )); 

and exception:

typeerror: property 'next' of object #<context> not function     @ context.actions.error 

what doing wrong? thanks!

edit:

    req._passport.instance.authenticate('local', function (err, user, info) {         if (err) return validator.emit('exception', err);          if (!user) {             validator.result.errors.push('username , 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); 

ok silly me, missed next @ end

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

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -