登录
注册
node.js 学习社区
passport.authenticate异常

justin

2016-09-08 15:40

express 4.13.4

mongoose 4.5.10

passport 0.3.2

passport-local  1.0.0

passport-local-mongoose 4.0.0

passport.authenticate异常,不正常执行

router.post('/login', passport.authenticate('local', { successRedirect: '/', failureRedirect:'/login' }), function(req, res) {

console.log('router.post login');

//console.log('req.username:' + req.username + ', req.password:'+ req.password);

});


router.get('/login', function(req, res) {

console.log('router.get login');

res.render('login', { user : req.user, title: 'Express' });

});

执行信息如下:

POST /login 302 4.481 ms - 56

router.get login

GET /login 200 3.558 ms - 574

可以看到console.log('router.post login');未被执行,

如果去掉passport.authenticate变成如下模样就能正确执行

router.post('/login', function(req, res) {

console.log('router.post login');

//console.log('req.username:' + req.username + ', req.password:'+ req.password);

});


请问passport.authenticate出什么问题了?

谢谢


回复 · 1

发表回复

你可以在回复中 @ 其他人