Implement Discord linking
Some checks failed
/ build (push) Failing after 4m43s

This commit is contained in:
Jorge Vargas 2025-03-21 11:35:03 -06:00
parent 0ec019f959
commit 4cafc41b88
11 changed files with 192 additions and 77 deletions

View file

@ -1,6 +1,7 @@
import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import { username, bearer } from 'better-auth/plugins'
import { DISCORD_OAUTH_ID, DISCORD_OAUTH_SECRET } from 'astro:env/server'
import prismaClient from './utils/prisma-client'
import { sendEmail } from './utils/email'
@ -11,6 +12,19 @@ export const auth = betterAuth({
database: prismaAdapter(prismaClient, { provider: 'mysql' }),
user: { modelName: 'users' },
plugins: [username(), bearer()],
account: {
accountLinking: {
enabled: true,
allowDifferentEmails: true
}
},
socialProviders: {
discord: {
clientId: DISCORD_OAUTH_ID,
clientSecret: DISCORD_OAUTH_SECRET,
scope: ['identify', 'email', 'guilds.members.read']
}
},
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,