From 67317f86b53240fb3c51afbd5784aa799e1231ae Mon Sep 17 00:00:00 2001 From: pradeepkumar Date: Fri, 20 Mar 2026 17:05:15 +0530 Subject: [PATCH] feat: Redirect ADMIN and SUPER_ADMIN users from web app routes to the logout page. --- src/middleware.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/middleware.ts b/src/middleware.ts index 62954b8..cce59b5 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -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));