Replies: 1 comment
-
Remix will eventually add middleware, until then the recommendation is to call isAuthenticated in any route you want to protect. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, Hope you're doing great!
Recently implemented the authentication for my application and reached a sort of dead-end due to the way I implemented my routes (since it's a dashboard). I'm not using any sub-routes (in the sense of
remix
) where I have nested layouts. My overall layout in set in my root.The reason I brought this up is that I can't provide
isAuthentication
to myroot
or_index
to have a fixed authentication in place because :root
will create an infinite loop._index
doesn't share any context with other parts of the routes.Q: I was wondering if you have any consideration for such scenarios?
After a while, I realized that it's a repeated task! which you are aware of: using
isAuthentication
withfailureRedirect
in all sub-routes!What if we get the best of both options I mentioned above?
I propose getting an additional parameter in your Authenticator class as
authUrl
and allow developers to useisAuthenticated
in their root loaders.Example:
I believe there's a nicer way to accomplish this, which I leave it up to you.
With this, it's possible to insert the function in the root loader :
if there is any alternative, please share it with me. THANKS.
Beta Was this translation helpful? Give feedback.
All reactions