feat: protect admin routes with OIDC roles

This commit is contained in:
Rémi 2025-01-05 02:10:54 +01:00
parent f0b498ca18
commit d45f79a3d9

View File

@ -17,6 +17,14 @@ export async function middleware(req: NextRequest) {
return NextResponse.redirect(url); return NextResponse.redirect(url);
} }
if (
!token?.user.roles.includes("admin") &&
url.pathname.startsWith("/admin")
) {
url.pathname = "/";
return NextResponse.redirect(url);
}
return NextResponse.next(); return NextResponse.next();
} }