feat(frontend): Add ogranization invitation

This commit is contained in:
2025-04-18 18:58:06 +02:00
parent 068dc1305f
commit 9c1cefd4ed
8 changed files with 325 additions and 26 deletions

View File

@@ -1,9 +1,23 @@
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()]
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}`
})
}
})
]
})

View File

@@ -0,0 +1,3 @@
import { Resend } from 'resend'
export const resend = new Resend(process.env.RESEND_API_KEY)