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

integrate with react-router v4 #12

Open
burczu opened this issue Mar 28, 2017 · 9 comments
Open

integrate with react-router v4 #12

burczu opened this issue Mar 28, 2017 · 9 comments
Assignees

Comments

@burczu
Copy link
Owner

burczu commented Mar 28, 2017

As the new version of react-router is completely rewriten, it would be nice to add support for this version of react-router. Or maybe it is completely unnecesary now?

@burczu burczu self-assigned this Mar 28, 2017
@clairekh
Copy link

Are you planning support react-router v4?

@mstruensee
Copy link

bump ... Are you planning support react-router v4?

@burczu
Copy link
Owner Author

burczu commented Jul 12, 2017

yeah, there is such plan but I had no time for that recently... I will try to take a look at this in August

@mstruensee
Copy link

mstruensee commented Jul 12, 2017

if it helps at all, i had it (or so i thought) implemented ... it just didn't get the "roles" from the route ... when i hard coded things, it hid and showed as expected ...

thanks for the update.

edit:
After doing some research, the first issue I noticed was this ...
You should not use and in the same route; will be ignored

the proposed solution is to change
<Route authorize={['admin']} component={RestrictedContainer}> <Route component={RestrictedPageComponent} path="/restricted" /> </Route>
to ...
<RestrictedContainer authorize={['admin']}>

`

Doing that caused an undefined in AuthorizedComponent.componentWillMount() ...
const { routes } = this.props; as it is no longer a "Route"

for my hard coded testing i did ...
const routeRoles = this.props.authorize

then I had to change
handleUnauthorizedRole(routeRoles, userRoles) { const {router} = this.context; router.push(this.notAuthorizedPath); }
to
handleUnauthorizedRole(routeRoles, userRoles) { const {router} = this.context; router.history.push(this.notAuthorizedPath); }

and of course i updated the required fields
static propTypes = { authorize: PropTypes.array.isRequired };

this all works when typing the URL manually into the browser, but when accessing it via LINK then it still loads when it shouldn't. After adding RoleAwareComponent, it loaded null but still went to my endpoint. Is this the current behavior?

@mstruensee
Copy link

any update on this?

@jgardezi
Copy link

jgardezi commented Feb 7, 2018

+1 need this.

@zenit1scada
Copy link

+1

2 similar comments
@gaetandezeiraud
Copy link

+1

@vireshshah
Copy link

+1

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

7 participants