This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import NextAuth from "next-auth"
|
||||
import Google from "next-auth/providers/google"
|
||||
|
||||
import { isAdminEmail } from "@/lib/admin-auth"
|
||||
|
||||
export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
providers: [Google],
|
||||
pages: {
|
||||
signIn: "/sign-in",
|
||||
error: "/auth-error",
|
||||
},
|
||||
trustHost: true,
|
||||
callbacks: {
|
||||
signIn({ profile, user }) {
|
||||
const email = user.email ?? (typeof profile?.email === "string" ? profile.email : null)
|
||||
|
||||
return isAdminEmail(email)
|
||||
},
|
||||
authorized({ auth }) {
|
||||
return isAdminEmail(auth?.user?.email)
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user