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

Dynamic redirect route handler #585

Open
Tracked by #239
valichek opened this issue Mar 27, 2018 · 6 comments
Open
Tracked by #239

Dynamic redirect route handler #585

valichek opened this issue Mar 27, 2018 · 6 comments
Assignees

Comments

@valichek
Copy link

I'm submitting a feature request

Having possibility to redirect from route handler would be a nice feature
For example sometimes I need redirect with some logic.
This could look like following:

{ route: '', redirect: (params, navigationInstruction) => {
    return Promise.resolve(new Redirect('new-path')) // or return new Redirect('new-path'), or 'new-path'
} },

Current behavior:

Now it's possible to handle redirect in modelView handlers like canActivate(). So I need to create dummy module and place redirection logic to canActivate().

@davismj
Copy link
Member

davismj commented Mar 27, 2018

@valichek can you give me a real example? It seems like it could be useful but I can't think of a valid use case.

@valichek
Copy link
Author

@davismj real use case: we have ACLs, child router is configured with all possible routes, navigation menu is filtered according to ACL, user can switch role any time, depending on role default route in child router can be different.

@valichek
Copy link
Author

valichek commented Mar 27, 2018

@davismj another use case, consider we want to handle /shop/SHOP_ID/admin route and redirect to /user/USER_ID/profile. This is not good example from app side, but shows ability to "convert" links

@davismj
Copy link
Member

davismj commented Apr 8, 2018

@valichek and AuthorizeStep doesn't solve this use case?

@valichek
Copy link
Author

valichek commented Apr 8, 2018

@davismj AuthorizeStep is good only for AppRouter, but not for its childRouters

@ItWorksOnMyMachine
Copy link

ItWorksOnMyMachine commented Aug 17, 2020

We have routes that look like '/clients/module' and want to change to '/clients/:clientId/module' but we have a lot of places where the old routes still exist (emails we sent, user's bookmarks, etc.) that are beyond our control. The solution proposed here would help us to create a dynamic redirector that would capture any navigation event to the old URL, inspect the current user's state information, and redirect to the new url with the :clientId parameter in place.

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

No branches or pull requests

3 participants