How to update req.user session object set by passportjs?

前端 未结 5 1294
抹茶落季
抹茶落季 2020-12-17 10:49

I\'m trying to do this since a lot of days but all my tests fails...

Users on my platform connect them by using passportjs strategies (paypal, facebook, google...).<

5条回答
  •  感动是毒
    2020-12-17 11:29

    I got the same problem and finally I found the solution:

    var user = newDataObj;
    req.logIn(user, function(error) {
        if (!error) {
           console.log('succcessfully updated user');
        }
    });
    res.end(); // important to update session
    

    The req.logIn will call serialize function and save a new session to db. res.end() is important. without it the session will not be saved.

提交回复
热议问题