How to set role from authprovider in accesControlProvider
right now i am following the tutorial from acces control tutorial, at that tutorial it set role manually in localstorage. but i want to get the role after i login and get it from authprovider. how to achieve that? when i try to use useGetIdentity directly like this it shows error
const { data: identity } = useGetIdentity<Iidentity>();
const roles = identity?.role ?? "guest"; // Default to "guest" if no role is found
const role = sessionStorage.getItem("role");
return (
<BrowserRouter>
<RefineKbarProvider>
<ColorModeContextProvider>
<AntdApp>
<Refine
dataProvider={dataProvider(`${backend}`)}
notificationProvider={useNotificationProvider}
routerProvider={routerBindings}
authProvider={authProvider}
accessControlProvider={{
can: async ({ action, params, resource }) => {
const enforcer = await newEnforcer(model, adapter);
if (
action === "delete" ||
action === "edit" ||
action === "show"
) {
return Promise.resolve({
can: await enforcer.enforce(
role,
`${resource}/${params?.id}`,
action
),
});
} const { data: identity } = useGetIdentity<Iidentity>();
const roles = identity?.role ?? "guest"; // Default to "guest" if no role is found
const role = sessionStorage.getItem("role");
return (
<BrowserRouter>
<RefineKbarProvider>
<ColorModeContextProvider>
<AntdApp>
<Refine
dataProvider={dataProvider(`${backend}`)}
notificationProvider={useNotificationProvider}
routerProvider={routerBindings}
authProvider={authProvider}
accessControlProvider={{
can: async ({ action, params, resource }) => {
const enforcer = await newEnforcer(model, adapter);
if (
action === "delete" ||
action === "edit" ||
action === "show"
) {
return Promise.resolve({
can: await enforcer.enforce(
role,
`${resource}/${params?.id}`,
action
),
});
}