feat: protect admin routes with OIDC roles
This commit is contained in:
parent
f0b498ca18
commit
d45f79a3d9
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user