Auto Login
Enforce authentication everywhere in your app.
Last updated
Was this helpful?
Enforce authentication everywhere in your app.
Last updated
Was this helpful?
If your application requires users to be authenticated at all times—such as dashboards or admin panels—you can configure oidc-spa to automatically redirect unauthenticated users to the login page. This ensures that no part of your app is accessible without authentication.
This is similar to wrapping your root component with withLoginEnforced()
, but with a key difference: oidc-spa assumes the user will never be unauthenticated. This means you do not need to:
Check isUserLoggedIn
, as it will always be true
.
(React) Use the assertion useOidc({ assert: "user logged in" })
, since the user is guaranteed to be logged in.
(React) Use withLoginEnforced
, it is not exposed in this mode since it is always enforced.
(React) You don't need to call enforceLogin()
in your loaders.