export const auth = betterAuth({
baseURL: env.BETTER_AUTH_URL,
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,
sendVerificationEmail: async ({ user, url }) => {
await sendEmailVerification(user.email, url);
},
},
emailAndPassword: {
enabled: true,
minPasswordLength: 8,
maxPasswordLength: 40,
autoSignIn: true,
sendResetPassword: async ({ user, url }) => {
await sendResetPassword(user.email, url);
},
password: {
hash: async (password) => await Bun.password.hash(password),
verify: async ({ hash, password }) =>
await Bun.password.verify(password, hash),
},
},
trustedOrigins: ["http://localhost:3000"],
plugins: [
captcha({
provider: "cloudflare-turnstile",
secretKey: env.TURNSTILE_SECRET_KEY,
}),
emailOTP({
async sendVerificationOTP({ email, otp, type }) {
if (type === "forget-password") await sendResetPasswordOTP(email, otp);
},
}),
username({
maxUsernameLength: 25,
minUsernameLength: 3,
}),
admin(),
openAPI(),
],
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
session: {
expiresIn: 60,
updateAge: 0,
freshAge: 0,
},
advanced: {
cookiePrefix: "rcp",
},
});
export const auth = betterAuth({
baseURL: env.BETTER_AUTH_URL,
emailVerification: {
sendOnSignUp: true,
autoSignInAfterVerification: true,
sendVerificationEmail: async ({ user, url }) => {
await sendEmailVerification(user.email, url);
},
},
emailAndPassword: {
enabled: true,
minPasswordLength: 8,
maxPasswordLength: 40,
autoSignIn: true,
sendResetPassword: async ({ user, url }) => {
await sendResetPassword(user.email, url);
},
password: {
hash: async (password) => await Bun.password.hash(password),
verify: async ({ hash, password }) =>
await Bun.password.verify(password, hash),
},
},
trustedOrigins: ["http://localhost:3000"],
plugins: [
captcha({
provider: "cloudflare-turnstile",
secretKey: env.TURNSTILE_SECRET_KEY,
}),
emailOTP({
async sendVerificationOTP({ email, otp, type }) {
if (type === "forget-password") await sendResetPasswordOTP(email, otp);
},
}),
username({
maxUsernameLength: 25,
minUsernameLength: 3,
}),
admin(),
openAPI(),
],
database: drizzleAdapter(db, {
provider: "pg",
usePlural: true,
}),
session: {
expiresIn: 60,
updateAge: 0,
freshAge: 0,
},
advanced: {
cookiePrefix: "rcp",
},
});