foolish-indigoF
Refine2y ago
8 replies
foolish-indigo

Root access with Casbin

I'm running on a standard React with Supabase build. I have Casbin set up with 3 user roles (superAdmin, admin, user). I've been following along with this tutorial: https://refine.dev/blog/refine-pixels-6. So far it's pretty much working as expected during the setup, but I'm unable to get get permissions set for the site route. The following just says that the user doesn't have permission:
p, superAdmin, , (list)|(show)|(edit)|(delete)
p, admin, , (list)|(show)|(edit)|(delete)
p, user, , (list)|(show)|(edit)


My routes look like the following:

<Routes>
    <Route
        element={
            <Authenticated key='authenticated-inner' fallback={<CatchAllNavigate to='/login' />}>
                <Layout Header={() => <Header sticky />} Sider={(props) => <Sider {...props} fixed />} Title={Title}>
                    <CanAccess fallback={<NoPermission />}>
                        <Outlet />
                    </CanAccess>
                </Layout>
            </Authenticated>
        }
    >
        <Route index element={<Dashboard />} />
        <Route path='/dashboard'>
            <Route index element={<Dashboard />} /> {/* Just a show component */}
        </Route>
        {/* Other routes... */}
        <Route path='*' element={<ErrorComponent />} />
    </Route>
    <Route
        element={
            <Authenticated key='authenticated-outer' fallback={<Outlet />}>
                <NavigateToResource />
            </Authenticated>
        }
    >
    </Route>
</Routes>
Was this page helpful?