Using a combination of Express-session, Connect-mongo and PassportJS on a Node server I have the following validation function:
expressApp.post('/login', function(req, res, next) {
passport.authenticate('login', function(err, user, info) {
if(err) {
return console.log(err);
}
if(!user){
res.set('WWW-Authenticate', 'x' + info);
return res.send(401);
}
req.login(user, function(err){
if(err) {
return console.log(err);
}
//I WANT TO ACCESS OUTGOING COOKIE HERE
//var cookie = res.get('SET-COOKIE');
res.redirect('/homepage');
});
}
)(req, res, next)
}
);
As you can see in the commented part, I want to access the cookie information before response is sent to the client. I haven't been able to find any such data within the 'res' and 'user' object.
Specifically I'm looking for the same string you can locate within the 'SET-COOKIE' header in a HTTP response.