I have a page that I use to check the user authorization
const Routes = auth => {
return (
<div className="view-routes">
//...
<PrivateRoute
path="/"
component={Entities}
hasAnyAuthorities={[AUTHORITIES.USER, AUTHORITIES.ADMIN]}
/>
// so in this case, the hasAnyAuthorities check if the user has one of this role and return true so I will see the component Entities for this user.
)}
Now I need to add another user's role. So I have add :
const Routes = auth => {
return (
<div className="view-routes">
//...
<PrivateRoute
path="/"
component={Menu2}
hasAnyAuthorities={[AUTHORITIES.USER_APP]}
/>
<PrivateRoute
path="/"
component={Entities}
hasAnyAuthorities={[AUTHORITIES.USER, AUTHORITIES.ADMIN]}
/>
)}
In this way only the first component (menu2) is always shown. So if I enter with role "USER_APP" I can see the fields in component Menu2. But if I login with role: "ADMIN" I can't see fields inside Entities, as if only the first of the two PrivateRoute were controlled.
What would to obtain:
If I enter with role: USER_APP I'll see the fields in component Menu2.
If I ente with role ADMIN I'll see the fields in the component Entities.
How can I do?