Only allow single NextAuth provider, Login middleware updates

This commit is contained in:
Darren Clarke 2024-09-27 14:52:44 +02:00
parent f86ce1e835
commit 8736b576a7
6 changed files with 111 additions and 99 deletions

View file

@ -85,9 +85,6 @@ const checkRewrites = async (request: NextRequestWithAuth) => {
};
export default withAuth(checkRewrites, {
pages: {
signIn: `/login`,
},
callbacks: {
authorized: ({ token, req }) => {
if (process.env.SETUP_MODE === "true") {
@ -97,6 +94,10 @@ export default withAuth(checkRewrites, {
const path = req.nextUrl.pathname;
const roles: any = token?.roles ?? [];
if (path.startsWith("/login")) {
return true;
}
if (path.startsWith("/admin") && !roles.includes("admin")) {
return false;
}