jaredhanson / jaredhanson/passport-github
redirect back to specific address
- Dominant language
- JavaScript
- Stars
- 535
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
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:
```javascript
// 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
No repository file or test is named; start with the authentication and callback routes shown in the issue. Determine how the initiating route could be preserved across the GitHub callback, with success returning the user to that route rather than `/`; the issue is complete when that behavior is defined and verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github, javascript, node.js
- Domain
- api, authentication, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100