add config for if github auth is enabled. room for more...

This commit is contained in:
Thomas Ruoff
2026-03-03 22:21:34 +01:00
parent 899bc86967
commit e3d67fbe8a
3 changed files with 10 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import { mongodbAdapter } from "better-auth/adapters/mongodb"
import { MongoClient, ServerApiVersion } from "mongodb"
import { MONGO_URI } from "../db"
import nodemailer from "nodemailer"
import { getConfig } from "../helpers/config"
async function sendEmail({ to, subject, url }: { to: string; subject: string; url: string }) {
const transporter = nodemailer.createTransport({
@@ -28,7 +29,7 @@ const ADMIN_EMAIL = process.env.ADMIN_EMAIL
const GITHUB_USERS_GRANTED = ['111471']
const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID;
const GITHUB_CLIENT_SECRET = process.env.GITHUB_CLIENT_SECRET;
const GITHUB_ENABLED = Boolean(GITHUB_CLIENT_SECRET?.length && GITHUB_CLIENT_ID?.length);
const { githubAuthEnabled } = getConfig();
const client = new MongoClient(MONGO_URI, {
serverApi: {
@@ -47,7 +48,7 @@ export const auth = betterAuth({
},
}),
],
...(GITHUB_ENABLED ? {
...(githubAuthEnabled ? {
socialProviders: {
github: {
provider: 'github',