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

Track initial URL request to redirect to after login/signup #109

Closed
CharlesIrvineKC opened this issue Jan 9, 2018 · 1 comment
Closed
Assignees
Labels

Comments

@CharlesIrvineKC
Copy link

I want to implement the following functionality:

  1. A potential, not-signed-up user clicks on a link to authenticated content in my web app.
  2. The user is automatically taken to my sign up page.
  3. The user signs up and is then taken to the linked page.
  4. I use React Router.

Is this supported by pup? Any suggestions on a way to implement?

Thanks,
Chuck

@cleverbeagle
Copy link
Owner

Hi @ChuckIrvine, this isn't directly in Pup but is possible. It involves a few steps:

  1. The best place to start is by converting the /imports/ui/layouts/App/App.js component to a class-based component so that it has access to React state.
  2. Next, you'll need to get access to the initial page the user is trying to access. This can come from JavaScript by looking at window.location when the page loads, or, you may be able to get this by implementing a custom router history and listening to it for changes. The idea here is that you use the history package to create a custom history and then pass it to the <Router /> component as the history prop.
  3. Once you have the location they were trying to visit, you can set that on the <App /> component's this.state value. If you pass that (this.state.redirectTo, for example) down to your /login or /signup page, immediately after login you can say history.push(this.props.redirectTo) and go from there.

All of that said, I'm going to convert this into a feature request to implement into Pup. Far too many steps to have to guess/cobble together.

@cleverbeagle cleverbeagle self-assigned this Jan 10, 2018
@cleverbeagle cleverbeagle changed the title user follow link, signup, navigate to authenticated page Track initial URL request to redirect to after login/signup Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants