Skip to content

Commit

Permalink
Document how to get introspection to work on any route (#1808)
Browse files Browse the repository at this point in the history
The previously documented solution would only trigger introspection on
the `/` route. Users directly navigating to a resource without being
authenticated (eg. navigating to `/#/books` and then being redirected to
the authentication page) would not hit the `<Route path="/">`, and thus
wouldn't trigger introspection after authenticating.

If `redirectToLogin` is `true`, the `<Resource>`es shouldn't be defined
in the application because otherwise they will register the specific
routes, e.g. `/#/books`, meaning the `<Route path="/:any">` wouldn't be
selected, and introspection also would not be triggered.
  • Loading branch information
Jayfrown authored Oct 16, 2023
1 parent 03c7614 commit a6bffb0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions admin/authentication-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,17 @@ const Admin = () => {
</Head>

<HydraAdmin dataProvider={dataProvider(setRedirectToLogin)} authProvider={authProvider} entrypoint={window.origin}>
<CustomRoutes>
{redirectToLogin ? <Route path="/" element={<RedirectToLogin />} /> : null}
</CustomRoutes>
{redirectToLogin ? (
<CustomRoutes>
<Route path="/" element={<RedirectToLogin />} />
<Route path="/:any" element={<RedirectToLogin />} />
</CustomRoutes>
) : (
<>
<Resource name=".." list="..">
<Resource name=".." list="..">
</>
)}
</HydraAdmin>
</>
);
Expand Down

0 comments on commit a6bffb0

Please sign in to comment.