main layout
This commit is contained in:
@@ -28,11 +28,8 @@ export default auth((req) => {
|
||||
|
||||
// Redirect logged-in users away from public routes (login, signup)
|
||||
if (isLoggedIn && isPublicRoute) {
|
||||
// Redirect to appropriate dashboard based on role
|
||||
if (userRole === "AGENT") {
|
||||
return NextResponse.redirect(new URL("/agent/dashboard", nextUrl.origin));
|
||||
}
|
||||
return NextResponse.redirect(new URL("/user/dashboard", nextUrl.origin));
|
||||
// Redirect to home page instead of dashboard
|
||||
return NextResponse.redirect(new URL("/", nextUrl.origin));
|
||||
}
|
||||
|
||||
// Redirect non-logged-in users to login page for protected routes
|
||||
@@ -46,7 +43,7 @@ export default auth((req) => {
|
||||
if (isLoggedIn) {
|
||||
// Prevent regular users from accessing agent routes
|
||||
if (isAgentRoute && userRole !== "AGENT") {
|
||||
return NextResponse.redirect(new URL("/user/dashboard", nextUrl.origin));
|
||||
return NextResponse.redirect(new URL("/user/userprofile", nextUrl.origin));
|
||||
}
|
||||
|
||||
// Prevent agents from accessing user routes
|
||||
|
||||
Reference in New Issue
Block a user