I'm currently using nextjs 14 and I am working on developing a website similar to a property app. It will have an admin dashboard and a user side. How can I ensure the security of both the admin and user sides, and what should my folder structure look like?
I know that middleware can be used for this purpose, but I need detailed guidance on how to implement it.
I have attempted having two layouts - one for authentication, one for the dashboard, and one for the user side. My goal is to restrict access so that when a user is logged in, they can only see pages related to the user side. Similarly, when an admin is logged in, they should have access to all admin dashboard pages.
If no one is logged in, the user should be redirected straight to the login page without being able to access any other pages. Unfortunately, I am facing challenges implementing this functionality.