Closed chef-louis closed 1 month ago
Refactored the auth group layout.tsx files by adding individual layout.tsx files for each protected path to check for an authenticated user. If there is no authenticated user then the page redirects to the login page with a redirect url parameter which is used by the login page for subsequent redirecting.
Dynamic redirect logic via federated sign-in is a bit more tricky as it's not possible to have the OAuth provider add a query parameter for us on the redirect URL. That said, after some quick research it looks like there are 2 viable solutions:
state
parameter to be modified and sent back, which we may be able to tweak / leverage conditionally
But if user visited '/login' or '/register', they should be redirected to profile page