Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect back to specific address #64

Open
proshoumma opened this issue Mar 29, 2017 · 2 comments
Open

redirect back to specific address #64

proshoumma opened this issue Mar 29, 2017 · 2 comments

Comments

@proshoumma
Copy link

Hi, currently I'm able to redirect the user to a "failureRedirect" and to a "successRedirect". Is it possible to redirect the user to the current route of the application? Like, I have the login button at the header and it's constant to every route of my application. Now, if a user is on a different route and try to log in, they are getting redirect to root route. I want to redirect them to the current route they are in at that point.

Could you please let me know if it's possible? I'm using the following code:

// github authentication route
app.get(
  '/api/user/authViaGitHub',
  passport.authenticate('github')
);

// callback route from github
app.get(
  // this should match callback url of github app
  '/api/user/authViaGitHub/callback',
  passport.authenticate('github', { failureRedirect: '/signIn/failed' }),
  (req, res) => { res.redirect('/'); }
);

I was thinking of sending a query with current route. But while the callback occurs, I'm not sure how should I redirect back according to the query since they are different requests.

@ghost
Copy link

ghost commented Apr 8, 2017

put passport.authenticate('github', { failureRedirect: customURL })(req, res, next) inside a callback function

@xiaoxiongzi
Copy link

I also have this problem, do you have solved it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants