Block a restricted page in React-Admin application

22 views Asked by At

In a React-Admin app, is there some way to prevent a user from visiting a specific?

The problem I want to address is where a user, who has access to https://example.com/regular-content/, hacks the url to directly visit https://example.com/privileged-content/.

My App.js already contains custom routes:

const App = () => (
  <Admin
    ...
  >
    <CustomRoutes>
      <Route path="/somepath" element={<CustomComponent />} />
    </CustomRoutes>

    {permissions === 'DEVELOPER' || permissions === 'ADMIN' ? (
      <Resource
        name="administration"
        options={{ label: 'Administration' }}
        list={Administration}
      />
    ) : null}

  </Admin>
);

But elsewhere in the app, let's say on that Administration list page, I have buttons that take the user to separate static pages:

<>
  <Button label="regular content" url="/regular-content/" />
  <Button label="privileged content" url="/privileged-content/" />
</>

Is there a way, say in my App.js by using custom routing, to use permissions to block the privileged content from a regular user?

Only the client side is using React-Admin. The server side is using Java.

Those content pages are actually hosted through another service as well. They aren't themselves rendered as part of my React-Admin app.

0

There are 0 answers