mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-04 01:44:13 +00:00
feat(client): let a managed route require an admin
Hiding the nav entry is not access control: the path stays typeable, and a screen about how the install is run should not open for somebody who was invited to one trip. ProtectedRoute already knows how to refuse — the attachment point just was not asking it to. Optional, so a route that does not set it behaves exactly as before. It sits next to adminOnly on the nav entry rather than being derived from it, because the two answer different questions: who is offered the door, and who may walk through it.
This commit is contained in:
+1
-1
@@ -479,7 +479,7 @@ export default function App() {
|
||||
<Route
|
||||
key={r.path}
|
||||
path={r.path}
|
||||
element={<ProtectedRoute>{r.element}</ProtectedRoute>}
|
||||
element={<ProtectedRoute adminRequired={r.adminOnly}>{r.element}</ProtectedRoute>}
|
||||
/>
|
||||
))}
|
||||
<Route
|
||||
|
||||
@@ -29,6 +29,15 @@ export interface ManagedRoute {
|
||||
path: string
|
||||
/** Rendered inside the app's ProtectedRoute wrapper, like every other screen. */
|
||||
element: ReactElement
|
||||
/**
|
||||
* Refuse the route to anyone but an admin, the same way /admin does.
|
||||
*
|
||||
* Hiding the nav entry is not access control — the path is still typeable, and
|
||||
* a screen about how the install is run should not open for a traveller who
|
||||
* was invited to one trip. Set this alongside `adminOnly` on the matching nav
|
||||
* entry; the two answer different questions.
|
||||
*/
|
||||
adminOnly?: boolean
|
||||
}
|
||||
|
||||
export interface ManagedNavItem {
|
||||
|
||||
Reference in New Issue
Block a user