24 lines
816 B
TypeScript
24 lines
816 B
TypeScript
import { betterAuth } from 'better-auth'
|
|
import Database from 'better-sqlite3'
|
|
import { organization } from 'better-auth/plugins'
|
|
import { resend } from './mail'
|
|
|
|
export const auth = betterAuth({
|
|
database: new Database('./sqlite.db'),
|
|
emailAndPassword: { enabled: true, autoSignIn: false },
|
|
plugins: [
|
|
organization({
|
|
async sendInvitationEmail(data) {
|
|
console.log('Sending invitation email', data)
|
|
const inviteLink = `http://localhost:3001/accept-invitation/${data.id}`
|
|
await resend.emails.send({
|
|
from: 'Acme <onboarding@resend.dev>',
|
|
to: data.email,
|
|
subject: 'Email Verification',
|
|
html: `You are invited to the Organization ${data.organization.name}! Click the link to verify your email: ${inviteLink}`
|
|
})
|
|
}
|
|
})
|
|
]
|
|
})
|