From cfab43e9a984542441ba0b2c64d97faf3079b1c9 Mon Sep 17 00:00:00 2001 From: Tianzhou Chen Date: Sun, 17 Dec 2023 22:33:13 +0800 Subject: [PATCH] chore: add next-auth-provider only if account is enabled --- src/pages/api/auth/[...nextauth].ts | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pages/api/auth/[...nextauth].ts b/src/pages/api/auth/[...nextauth].ts index c487b4d..7b2548d 100644 --- a/src/pages/api/auth/[...nextauth].ts +++ b/src/pages/api/auth/[...nextauth].ts @@ -14,21 +14,23 @@ const prisma = new PrismaClient(); export const authOptions: NextAuthOptions = { adapter: hasFeature("account") ? PrismaAdapter(prisma) : undefined, // https://next-auth.js.org/configuration/providers/oauth - providers: [ - EmailProvider({ - server: process.env.EMAIL_SERVER, - from: "noreply@sqlchat.ai", - // maxAge: 24 * 60 * 60, // How long email links are valid for (default 24h) - }), - GoogleProvider({ - clientId: process.env.GOOGLE_CLIENT_ID, - clientSecret: process.env.GOOGLE_CLIENT_SECRET, - }), - GithubProvider({ - clientId: process.env.GITHUB_ID, - clientSecret: process.env.GITHUB_SECRET, - }), - ], + providers: hasFeature("account") + ? [ + EmailProvider({ + server: process.env.EMAIL_SERVER, + from: "noreply@sqlchat.ai", + // maxAge: 24 * 60 * 60, // How long email links are valid for (default 24h) + }), + GoogleProvider({ + clientId: process.env.GOOGLE_CLIENT_ID, + clientSecret: process.env.GOOGLE_CLIENT_SECRET, + }), + GithubProvider({ + clientId: process.env.GITHUB_ID, + clientSecret: process.env.GITHUB_SECRET, + }), + ] + : [], cookies: { sessionToken: { name: `next-auth.session-token`,