AWS SES preview
This commit is contained in:
@@ -2,11 +2,13 @@ import { betterAuth } from 'better-auth';
|
||||
import { kyselyAdapter } from '@better-auth/kysely-adapter';
|
||||
import { Kysely, PostgresDialect } from 'kysely';
|
||||
import { Pool } from 'pg';
|
||||
import { sendEmail, verificationEmailHtml, resetPasswordEmailHtml } from './email';
|
||||
|
||||
const db = new Kysely({
|
||||
dialect: new PostgresDialect({
|
||||
pool: new Pool({
|
||||
connectionString: process.env.DATABASE_URL ||
|
||||
connectionString:
|
||||
process.env.DATABASE_URL ||
|
||||
'postgresql://labwise:labwise_dev_pw@localhost:5432/labwise_db',
|
||||
}),
|
||||
}),
|
||||
@@ -16,7 +18,35 @@ export const auth = betterAuth({
|
||||
database: kyselyAdapter(db, { type: 'postgres' }),
|
||||
|
||||
baseURL: process.env.BETTER_AUTH_URL || 'http://localhost:3001',
|
||||
secret: process.env.BETTER_AUTH_SECRET || 'dev-secret-change-in-production-min32chars!!',
|
||||
secret:
|
||||
process.env.BETTER_AUTH_SECRET ||
|
||||
'dev-secret-change-in-production-min32chars!!',
|
||||
|
||||
rateLimit: {
|
||||
enabled: false, // TODO: re-enable in production
|
||||
},
|
||||
|
||||
emailAndPassword: {
|
||||
enabled: true,
|
||||
requireEmailVerification: true,
|
||||
sendResetPassword: async ({ user, url }) => {
|
||||
await sendEmail({
|
||||
to: user.email,
|
||||
subject: 'Reset your LabWise password',
|
||||
html: resetPasswordEmailHtml(url),
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
emailVerification: {
|
||||
sendVerificationEmail: async ({ user, url }) => {
|
||||
await sendEmail({
|
||||
to: user.email,
|
||||
subject: 'Verify your LabWise email',
|
||||
html: verificationEmailHtml(url),
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
socialProviders: {
|
||||
google: {
|
||||
|
||||
Reference in New Issue
Block a user