Recommended way to handle unauthorized access and flash messages
Unanswered
Smaller yellow ant posted this in #help-forum
Smaller yellow antOP
Two parts, both within the context of the app router:
1) Is there a recommended way to handle unauthorized access on the server side? So if I don't have permission to view a given page, what do I do to the user? Redirect using redirect()? Throw an error?
2) If a user does not have permission to interact with a page, how can I set a flash message that will show up at some point after the error/redirect? If the auth logic is happening in page.tsx we don't have the ability to set cookies, which is how some other frameworks handle this problem, so what's the recommended way to go about setting a flash message?
Migrating over from django so still getting the hang of Next. Thank you for any help you can provide!
1) Is there a recommended way to handle unauthorized access on the server side? So if I don't have permission to view a given page, what do I do to the user? Redirect using redirect()? Throw an error?
2) If a user does not have permission to interact with a page, how can I set a flash message that will show up at some point after the error/redirect? If the auth logic is happening in page.tsx we don't have the ability to set cookies, which is how some other frameworks handle this problem, so what's the recommended way to go about setting a flash message?
Migrating over from django so still getting the hang of Next. Thank you for any help you can provide!