Skip to content
This repository has been archived by the owner on Aug 23, 2020. It is now read-only.

Enable redirection to previous page after 3rd party login #147

Open
JAertgeerts opened this issue Mar 30, 2017 · 5 comments
Open

Enable redirection to previous page after 3rd party login #147

JAertgeerts opened this issue Mar 30, 2017 · 5 comments

Comments

@JAertgeerts
Copy link
Contributor

JAertgeerts commented Mar 30, 2017

With the callback & redirect on the 3rd party providers, there is no way to return to the previous page prior to logging in.

Approach:

  • Ability to add a query param with the returnUrl to the auth route: like this api/v1/auth/$provider?returnUrl=$url
  • Set req.session.returnUrl = req.query.returnUrl when receiving the auth call in the controller
  • After receiving the callback from 3rd party, check the existence of session.returnUrl and use that instead of the config.login route - or add the url as a queryParam to the login redirect route (and remove session.returnUrl).

Will open PR on this later if you'd like...

@jaumard
Copy link
Owner

jaumard commented Mar 31, 2017

If there a way to make it work without sessions I will prefer this solution as I generally don't enable sessions when I use JWT. If ?returnUrl=$url can work go for this solution. And yes after connect/login with third party we check this param and redirect to that URL or config.login if empty.
Sorry if I can't currently help you to do that.

@JAertgeerts
Copy link
Contributor Author

@jaumard It's possible, but I gave this a thought and probably makes a lot more sense to just handle this on the frontend and store in the local storage when clicking the auth/provider url. I don't think this trailpack should be handling this. Do you agree?

@jaumard
Copy link
Owner

jaumard commented Apr 4, 2017

In some cases you cannot manage this in the front end, or you will be redirected to /login and then manually redirect to another page witch can look weird in the browser. I think it can be nice if it can manage here but it's not really mandatory for now :)

@JAertgeerts
Copy link
Contributor Author

I'll open a PR once I get the time to do so!

@jaumard
Copy link
Owner

jaumard commented Apr 21, 2018

@JAertgeerts I implemented this functionality on this branch https://github.com/jaumard/trailpack-passport/tree/feature/third_party work by using redirectTo query param, and only if you enable sessions. I can't merge the branch yet as I have trouble with the mongoose ORM which is broken.
If you're using it and have time to take a look please help :)
Thx

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

No branches or pull requests

2 participants