Redirect to original request after authentication, Angular-Fullstack?

I am using angular -fullstack ( https://github.com/DaftMonk/generator-angular-fullstack ) from the yeomen generator for the MEAN stack. I am new to most of these technologies, and I am just starting to hug around me how the shapes fit together.

I'm trying to figure out how to redirect an authenticated user to the URL they originally requested before they logged in.

AT

myproject/server/auth/auth.service.js

there is this function that seems to redirect back to '/' after logging in to oAuth:

/**
 * 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 can I recall the original query for both the username and the login, and then I would redirect the user after login? Thank!!

+4

All Articles