I followed the marmelab documentation for applying role base restrictions: https://marmelab.com/react-admin/doc/3.4/Authorization.html.
I have successfully applied to my resources section:"Restricting Access To Resources or Views" and to my menu section:"Restricting Access to a Menu". However, on thing that I think is missing on the documentation and that I haven't yet found a solution was how to apply this type of restrictions to the customRoutes.
function App() {
return (
<Admin
theme={MyTheme}
layout={MyLayout}
history={history}
customRoutes={[
<PrivateRoute
exact
path="/system-status"
component={props => <SystemStatusScreen {...props} />}
/>,
<PrivateRoute
exact
path="/social-media"
component={props => <SocialMediaScreen {...props} />}
/>,
}
catchAll={NotFound}
authProvider={authProvider}
loginPage={LoginPage}
dataProvider={dataProvider}
>
...
React-admin allows to define a usePermissions function to retrieve permissions but those permissions are not loaded outside the tag thus I cannot precalculate the routes to pass to the Admin component as they are undefined.
Can someone help me on this issue?
Thank you in advance.