From f367f00b6a31295882d69cf035e1c3e07fd7d3b7 Mon Sep 17 00:00:00 2001 From: Steve Sewell Date: Fri, 27 Mar 2026 12:13:07 -0700 Subject: [PATCH 1/3] fix: dev mode shows all Google accounts regardless of owner for shared Neon DB --- templates/mail/server/handlers/google-auth.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/mail/server/handlers/google-auth.ts b/templates/mail/server/handlers/google-auth.ts index 42ea0082..5fa53e3a 100644 --- a/templates/mail/server/handlers/google-auth.ts +++ b/templates/mail/server/handlers/google-auth.ts @@ -215,7 +215,11 @@ export const handleGoogleAddAccountCallback = defineEventHandler( export const getGoogleStatus = defineEventHandler(async (event: H3Event) => { try { const session = await getSession(event); - const status = await getAuthStatus(session?.email); + // In dev mode (local@localhost), show all connected accounts regardless of owner + // so tokens created in prod are visible locally and vice versa + const forEmail = + session?.email === "local@localhost" ? undefined : session?.email; + const status = await getAuthStatus(forEmail); return status; } catch (error: any) { setResponseStatus(event, 500); From ee1935d47e17e811d8c365974e407c35405a2a90 Mon Sep 17 00:00:00 2001 From: Steve Sewell Date: Fri, 27 Mar 2026 12:28:05 -0700 Subject: [PATCH 2/3] fix: move local@localhost owner bypass to lib layer for all Google auth callers --- templates/mail/server/handlers/google-auth.ts | 6 +----- templates/mail/server/lib/google-auth.ts | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/mail/server/handlers/google-auth.ts b/templates/mail/server/handlers/google-auth.ts index 5fa53e3a..42ea0082 100644 --- a/templates/mail/server/handlers/google-auth.ts +++ b/templates/mail/server/handlers/google-auth.ts @@ -215,11 +215,7 @@ export const handleGoogleAddAccountCallback = defineEventHandler( export const getGoogleStatus = defineEventHandler(async (event: H3Event) => { try { const session = await getSession(event); - // In dev mode (local@localhost), show all connected accounts regardless of owner - // so tokens created in prod are visible locally and vice versa - const forEmail = - session?.email === "local@localhost" ? undefined : session?.email; - const status = await getAuthStatus(forEmail); + const status = await getAuthStatus(session?.email); return status; } catch (error: any) { setResponseStatus(event, 500); diff --git a/templates/mail/server/lib/google-auth.ts b/templates/mail/server/lib/google-auth.ts index ab26844f..888dda14 100644 --- a/templates/mail/server/lib/google-auth.ts +++ b/templates/mail/server/lib/google-auth.ts @@ -235,7 +235,8 @@ export async function getClients( * checks only that specific account. */ export async function isConnected(forEmail?: string): Promise { - if (forEmail) { + // In dev mode, check all accounts regardless of owner + if (forEmail && forEmail !== "local@localhost") { const accounts = await listOAuthAccountsByOwner("google", forEmail); return accounts.length > 0; } @@ -263,7 +264,8 @@ export async function getAuthStatus( accountId: string; tokens: Record; }>; - if (forEmail) { + // In dev mode (local@localhost), show all accounts regardless of owner + if (forEmail && forEmail !== "local@localhost") { oauthAccounts = await listOAuthAccountsByOwner("google", forEmail); } else { oauthAccounts = await listOAuthAccounts("google"); From 01f3fe6579fcfa5ad2e973743de32d5c9848062a Mon Sep 17 00:00:00 2001 From: Steve Sewell Date: Fri, 27 Mar 2026 12:35:33 -0700 Subject: [PATCH 3/3] fix: labels not loading in dev mode, suppress Postgres notices - getAccountTokens skips owner filter for local@localhost (same as other auth fixes) - Suppress Postgres NOTICE messages for CREATE TABLE IF NOT EXISTS --- packages/core/src/db/client.ts | 4 +++- templates/mail/server/handlers/emails.ts | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/core/src/db/client.ts b/packages/core/src/db/client.ts index 33ebeac3..9e120f5f 100644 --- a/packages/core/src/db/client.ts +++ b/packages/core/src/db/client.ts @@ -105,7 +105,9 @@ async function initClient(): Promise { // Postgres — dynamically import to avoid bundling in non-Postgres runtimes if (dialect === "postgres") { const { default: postgres } = await import("postgres"); - _pgPool = postgres(url); + _pgPool = postgres(url, { + onnotice: () => {}, // Suppress CREATE TABLE IF NOT EXISTS notices + }); const pool = _pgPool; _exec = { diff --git a/templates/mail/server/handlers/emails.ts b/templates/mail/server/handlers/emails.ts index f32a83f0..3e4e12f1 100644 --- a/templates/mail/server/handlers/emails.ts +++ b/templates/mail/server/handlers/emails.ts @@ -97,9 +97,11 @@ async function getAccessToken(accountEmail: string): Promise { async function getAccountTokens( forEmail?: string, ): Promise> { - const accounts = forEmail - ? await listOAuthAccountsByOwner("google", forEmail) - : await listOAuthAccounts("google"); + // In dev mode (local@localhost), show all accounts regardless of owner + const accounts = + forEmail && forEmail !== "local@localhost" + ? await listOAuthAccountsByOwner("google", forEmail) + : await listOAuthAccounts("google"); const results: Array<{ email: string; accessToken: string }> = [];