Business Requirement
We need to implement middleware that hides or shows pages based on the logged-in user's role to ensure role-based access control across the application.
Acceptance Criteria
Implement a middleware that checks the user's role before allowing access to specific pages.
If the user’s role does not match the required role(s) for a page, redirect them to an appropriate page (e.g., homepage, login or error page).
Only administrators can access the admin panel pages.
Configure the middleware to support multiple roles (e.g., "member," "admin", "content-manager").
Apply the middleware to the following pages:
Admin Panel (restricted to "admin" role only)
Content Panel (accessible to "admin" and "content-manager" roles)
Platform(accessible to "members")
Ensure the middleware checks if the user is authenticated before checking their role.
If not authenticated, redirect to the login page.
Include appropriate error handling to manage unauthorized access attempts.
Test the middleware to ensure proper redirection and authorization enforcement for each role.
Business Requirement We need to implement middleware that hides or shows pages based on the logged-in user's role to ensure role-based access control across the application.
Acceptance Criteria
Documentation: https://nextjs.org/docs/app/building-your-application/routing/middleware