I have a condition where certain pages can be accessed according to their role in database
I have followed the tutorial on the Authjs site, and it seems like there is a lack of information, because there is an error in my coding
I use mongoose (mongodb), nextjs, and Google provider (OAuth)
My auth config:
import GitHub from "next-auth/providers/github"
import type { NextAuthConfig } from "next-auth"
import Google from "next-auth/providers/google"
import Credentials from "next-auth/providers/credentials"
export default {
providers: [
Google({
profile(profile) {
return { role: profile.role ?? "user", ...}
}
}),
]
} satisfies NextAuthConfig
Callbacks:
callbacks: {
async session({ session, token, user }) {
// `session.user.address` is now a valid property, and will be type-checked
// in places like `useSession().data.user` or `auth().user`
return {
...session,
user: {
...session.user,
},
}
},
},
The Error:
... Expression expected.
Middleware:
// export { auth as middleware } from "@/auth";
import NextAuth from "next-auth"
import authConfig from "./libs/auth-js/auth.config"
export const { auth: middleware } = NextAuth(authConfig)