Only allow single NextAuth provider, Login middleware updates
This commit is contained in:
parent
f86ce1e835
commit
8736b576a7
6 changed files with 111 additions and 99 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue