feat: Implement authentication checks for profile actions and user layout, and add presigned URL fetching for file viewing.

This commit is contained in:
pradeepkumar
2026-01-29 00:02:59 +05:30
parent 4ffd6305b1
commit b41bd8a3eb
9 changed files with 243 additions and 40 deletions

View File

@@ -5,7 +5,7 @@ import { NextResponse } from "next/server";
const authRoutes = ["/login", "/signup", "/forgot-password", "/reset-password", "/verify-email"];
// Public routes - accessible to everyone (logged in or not)
const publicRoutes = ["/", "/contact", "/about", "/faq"];
const publicRoutes = ["/", "/contact", "/about", "/faq", "/user/dashboard", "/user/profiles", "/user/profile"];
export default auth((req) => {
const { nextUrl } = req;
@@ -58,8 +58,8 @@ export default auth((req) => {
return NextResponse.redirect(new URL("/user/dashboard", nextUrl.origin));
}
// Prevent agents from accessing user routes
if (isUserRoute && userRole === "AGENT") {
// Prevent agents from accessing protected user routes (but allow public user routes)
if (isUserRoute && userRole === "AGENT" && !isPublicRoute) {
return NextResponse.redirect(new URL("/agent/dashboard", nextUrl.origin));
}
}