worthy-azureW
Refine3y ago
20 replies
worthy-azure

parent resource permission

I have two resource under a parent named settings. here settings is not an actual resource but we set it as a resource so we can show the child resources as nested inside the sidebar.
now my api provides a permission list which has all the permitted actions for each resource. so in accessControlProvider on Refine component we are checking on each resource that if the permission is available in the list and return can: true or false accordingly. since the settings is not a resource, the permission list doesn't have that one but it has permission for resource that are under the settings. but since the settings doesn't have permission the child resource also not showing in the sidebar.
how can i fix that

<Refine
accessControlProvider={{
can: canAccess,
}}
dataProvider={restDataPovider}
notificationProvider={notificationProvider}
resources={resourceList}
routerProvider={routerBindings}
authProvider={authProvider}
/>


const canAccess = useCallback(
async ({ resource, action, params }: CanParams): Promise<CanReturnType> => {
const allow = checkAccess({ resource, action, permissions, validate, params });
return Promise.resolve({
can: allow,
reason: "Unauthorized",
});
},
[permissions]
);
Was this page helpful?