How to check authority on submenu items in JHipster

Viewed 71

How to check for a certain authority in a submenu. ex. /admin/user-management page can be accessed by a user who has a certain authority.

<>
    <MenuItem icon="user" to="/admin/user-management">
      <Translate contentKey="global.menu.admin.userManagement">User management</Translate>
    </MenuItem>
    <MenuItem icon="tachometer-alt" to="/admin/metrics">
      <Translate contentKey="global.menu.admin.metrics">Metrics</Translate>
    </MenuItem>
    <MenuItem icon="tasks" to="/admin/logs">
      <Translate contentKey="global.menu.admin.logs">Logs</Translate>
    </MenuItem>
  </>
1 Answers

To get access to the isAuthenticated and isAdmin props, you have multiple options:

To restrict the paths, even for direct navigation, see the example in routes.tsx

Related