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

Add functionality to dispatch Route without change real URL #72

Closed
roadhump opened this issue Jul 8, 2014 · 5 comments
Closed

Add functionality to dispatch Route without change real URL #72

roadhump opened this issue Jul 8, 2014 · 5 comments

Comments

@roadhump
Copy link

roadhump commented Jul 8, 2014

It would be nice to have functionality (in transition and Router itself) to dispatch specific route without change real URL.

E.g. I have auth flow close to https://github.com/rpflorence/react-nested-router/tree/master/examples/auth-flow . I visit my auth-only page /secret. Then I must be redirected to my auth page and URL in my address bar is /auth/signin. But it would be better for user still see /secret as URL and have some auth Route as activeRoute. In such case if I press Refresh I still have /secret URL and can return to it after sign in. Now I have /auth/signin and can't it.

I see it as something like

// inside my AuthMixin
willTransitionTo: function(transition) {
    //...
   if (!loggedIn) {
     transition.abort();
     authService.setTransition(transition);
     transition.forward('/auth/signin')
  } 
}
@sophiebits
Copy link
Contributor

The usual way to do this on the web is to redirect to /auth/signin?continue=/secret or similar.

@ryanflorence
Copy link
Member

Interesting use case. I think I agree, the sign in step is a workflow within the secret app state.

I wonder if this is the routers job, or if I should just have a signin component that "secret" uses and my signin route uses it too.

Sent from my iPhone

On Jul 8, 2014, at 3:41 AM, Aliaksei notifications@github.com wrote:

It would be nice to have functionality (in transition and Router itself) to dispatch specific route without change real URL.

E.g. I have auth flow close to https://github.com/rpflorence/react-nested-router/tree/master/examples/auth-flow . I visit my auth-only page /secret. Then I must be redirected to my auth page and URL in my address bar is /auth/signin. But it would be better for user still see /secret as URL and have some auth Route as activeRoute. In such case if I press Refresh I still have /secret URL and can return to it after sign in. Now I have /auth/signin and can't it.

I see it as something like

// inside my AuthMixin
willTransitionTo: function(transition) {
//...
if (!loggedIn) {
transition.abort();
authService.setTransition(transition);
transition.forward('/auth/signin')
}
}

Reply to this email directly or view it on GitHub.

@mjackson
Copy link
Member

mjackson commented Jul 9, 2014

I agree with @spicyj. The URL should dictate the UI that's on the page, namely /auth/signin. Where to go after that shouldn't be part of the URL, but should instead be part of the query string. Then, after signin you can:

Router.transitionTo(this.props.query.continue || 'home');

@ryanflorence
Copy link
Member

I think my comments were ambiguous.

  1. URLs should always have meaning, they represent application states.
  2. We should not allow transitioning to a route w/o changing the URL.
  3. You don't need to save the next url into the url, you can just have "signin" be a workflow within a route, reusing a SigninForm component within an AuthenticatedMixin as well as the signin route handler.

@roadhump
Copy link
Author

I suppose you're right. I've investigated some of client and server side frameworks and found that it should not be concern of routing to replace one response with another. I'd like to close this issue.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants