From c5ec44b7c52961abfbdcd3dd3215d2751774ff22 Mon Sep 17 00:00:00 2001 From: Jackson M Meade Date: Sun, 8 Feb 2026 12:35:11 -0500 Subject: [PATCH] fix: remove autoverification from admin create user hook --- apps/auth/app.ts | 1 - shared/authentication/src/auth.definition.ts | 39 +++++++------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/apps/auth/app.ts b/apps/auth/app.ts index 33fe730..39674b0 100644 --- a/apps/auth/app.ts +++ b/apps/auth/app.ts @@ -55,7 +55,6 @@ if (process.env.NODE_ENV !== 'production') { } const userId = userResult[0].id; - const tokenPrefix = `${type}:`; const result = await db .select() diff --git a/shared/authentication/src/auth.definition.ts b/shared/authentication/src/auth.definition.ts index a590b23..1be3ed7 100644 --- a/shared/authentication/src/auth.definition.ts +++ b/shared/authentication/src/auth.definition.ts @@ -311,32 +311,21 @@ export const auth: Auth = betterAuth({ return; } - // Auto-verify email for admin-created users (admin is a trusted source) - // This avoids requiring email verification for accounts created by station managers - try { - await db - .update(user) - .set({ emailVerified: true }) - .where(eq(user.email, email)); - console.log(`Auto-verified email for admin-created user: ${email}`); - } catch (error) { - console.error('Error auto-verifying admin-created user email:', error); - // Still try to send verification email as fallback - const callbackURL = - process.env.EMAIL_VERIFICATION_REDIRECT_URL?.trim() || - process.env.FRONTEND_SOURCE?.trim(); + // Send verification email for admin-created users + const callbackURL = + process.env.EMAIL_VERIFICATION_REDIRECT_URL?.trim() || + process.env.FRONTEND_SOURCE?.trim(); - void auth.api - .sendVerificationEmail({ - body: { - email, - callbackURL, - }, - }) - .catch((verifyError) => { - console.error('Error triggering verification email:', verifyError); - }); - } + void auth.api + .sendVerificationEmail({ + body: { + email, + callbackURL, + }, + }) + .catch((error) => { + console.error('Error triggering verification email:', error); + }); }), },