feat: Redirect ADMIN and SUPER_ADMIN users from web app routes to the logout page.
This commit is contained in:
@@ -65,6 +65,14 @@ export default auth((req) => {
|
||||
|
||||
// Role-based route protection
|
||||
if (isLoggedIn) {
|
||||
// Block ADMIN and SUPER_ADMIN from web app — they should use admin panel
|
||||
if (userRole === "ADMIN" || userRole === "SUPER_ADMIN") {
|
||||
// Allow logout and public routes
|
||||
if (!isPublicRoute && !isNoRedirectRoute) {
|
||||
return NextResponse.redirect(new URL("/logout", nextUrl.origin));
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent regular users from accessing agent routes
|
||||
if (isAgentRoute && userRole !== "AGENT") {
|
||||
return NextResponse.redirect(new URL("/user/dashboard", nextUrl.origin));
|
||||
|
||||
Reference in New Issue
Block a user