我在验证时遇到问题。我使用护照模块和pg for postgres。此代码成功地将数据保存到数据库,但应用程序转到failureRedirect。有谁能够帮我?感谢
passport.use('local-signup', new LocalStrategy({
usernameField : 'username',
passwordField : 'password',
passReqToCallback : true // allows us to pass back the entire request to the callback
},
function(req, username, password, done) {
pg.connect(db.url, function(err, client) {
if(err) {
return done(err);
} else {
client.query('INSERT INTO users VALUES($1,$2)',
[req.body.nickname,req.body.password],function(err, result) {
return done(null, result.rows[0]);
});
}
});
}));
app.post('/register',passport.authenticate('local-signup',{
failureRedirect : '/register'}),function(req,res){
res.redirect('/login');
});