diff --git a/services/mana-core-auth/src/auth/better-auth.config.ts b/services/mana-core-auth/src/auth/better-auth.config.ts index ede5ed104..4203eb425 100644 --- a/services/mana-core-auth/src/auth/better-auth.config.ts +++ b/services/mana-core-auth/src/auth/better-auth.config.ts @@ -85,29 +85,13 @@ export function createBetterAuth(databaseUrl: string) { }, }), - // Email/password authentication with email verification and password reset + // Email/password authentication with password reset emailAndPassword: { enabled: true, requireEmailVerification: true, minPasswordLength: 8, maxPasswordLength: 128, - /** - * Email Verification - * - * Sends verification email when user registers. - * User must verify email before they can log in. - */ - sendVerificationEmail: async ({ - user, - url, - }: { - user: { email: string; name: string }; - url: string; - }) => { - await sendVerificationEmail(user.email, url, user.name); - }, - /** * Password Reset Configuration * @@ -128,6 +112,26 @@ export function createBetterAuth(databaseUrl: string) { }, }, + /** + * Email Verification Configuration + * + * Sends verification email when user registers. + * User must verify email before they can log in. + */ + emailVerification: { + sendOnSignUp: true, + autoSignInAfterVerification: true, + sendVerificationEmail: async ({ + user, + url, + }: { + user: { email: string; name: string }; + url: string; + }) => { + await sendVerificationEmail(user.email, url, user.name); + }, + }, + // Session configuration session: { expiresIn: 60 * 60 * 24 * 7, // 7 days