lundi 13 février 2017

specific successRedirect in passport.js with local strategy

Vote count: 0

I have a question about successRedirecting in passport.authenticate. I'm using passport.js and local strategy in nodejs and express for user login and trying to make specific successRedirect route.

For example, if I log in with user id: gpaul(pretended to be successed logging in), then successRedirect route is wanted to be '?channel=gpaul'.

I made the code like below

var data_1 = {email:''};
app.post('/login',
  function (req,res,next){
    req.flash("email");
    data_1.email = req.body.email;
    console.log(data_1.email);
    next();
  }, passport.authenticate('local-login', {
    successRedirect : ('/status.html?channel='+ data_1.email),
    failureRedirect : '/login',
    failureFlash : true
  })
);

After implementing above code, the address comes out with blank , localhost:4000/?channel= from the console log it comes out correctly, but in successRedirect, it doesn't work at all..

Does anybody have any ideas for specific successRedirecting? Please help me out here..

Thanks.

asked 37 secs ago

Let's block ads! (Why?)



specific successRedirect in passport.js with local strategy

Aucun commentaire:

Enregistrer un commentaire