I am using the angular-fullstack (https://github.com/DaftMonk/generator-angular-fullstack) from the yeoman generator for the MEAN stack. I am new to most of these technologies and am just beginning to wrap my head around how the pieces fit together.
I am trying to figure out how to redirect a freshly authenticated user to the URL that they originally requested before they logged in.
In
myproject/server/auth/auth.service.js
there is this function which appears to redirect back to '/' after an oAuth login:
/**
* Set token cookie directly for oAuth strategies
*/
function setTokenCookie(req, res) {
if (!req.user) return res.json(404, { message: 'Something went wrong, please try again.'});
var token = signToken(req.user._id, req.user.role);
res.cookie('token', JSON.stringify(token));
res.redirect('/');
}
How would I go about remembering the original request for both oAuth AND local login and then were would I redirect the user appropriately after they log in? Thanks!!