Hi guys. I want to make some private routes depending on what role a logged user ha but I found a problem. When I reload the page, while I’m logged in and in the right authenticated route, It redirects me to another page (/not-found). Here’s my example code:
I thought on using that, but… if i want to use it on N pages, I need to replicate this pattern instead of using it on router level. Is there any option to make this reusable?
For me this can’t be possible, since I have a main template (or main layout) that englobes all templates, with authentication and without authentication. With your solution, I’ll need to make one layout for each logged and not logged routes…right?
Actually that’s more complexity than just “see if you can go to this route before you can subscribe or render data”. Ofc I need to do those checks in pubs and methods, but actually, I just need to check if a logged user can “see” a determined route or “it don’t exists” for that user…
I can restructure them. But the only thing that changes between 2 or more layouts for this prupose are the authentication logic, so, it seems to me to re-doing the same view for one simple change (same menu, same sidebar, same footer, different authentication logic)