From 558cce44fa7b0f8923e16ed153f46faea8e6d63e Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Wed, 8 Jul 2026 11:57:44 +0000 Subject: [PATCH] Bust auth creds cache after saving workforce/smtp integrations After a successful PUT to /integrations/workforce or /integrations/smtp, fire-and-forget POST to auth's /internal/cache-bust so credential changes (including default location) propagate instantly without a container restart. Co-Authored-By: Claude Sonnet 4.6 --- src/routes/integrations.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/routes/integrations.js b/src/routes/integrations.js index 0328826..51533ca 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -5,6 +5,17 @@ import { INTEGRATIONS, MASKED } from '../integrations/schema.js' import { testConnection as newbookTest, fetchSiteList } from '../integrations/newbook.js' import { testConnection as resosTest } from '../integrations/resos.js' +const AUTH_URL = process.env.AUTH_URL || 'http://10.10.10.101:3001' + +function bustAuthCache() { + const secret = process.env.SETTINGS_SECRET || '' + fetch(`${AUTH_URL}/api/auth/internal/cache-bust`, { + method: 'POST', + headers: { Authorization: `Bearer ${secret}` }, + signal: AbortSignal.timeout(3000), + }).catch(() => {}) +} + function decryptSecrets(row) { if (!row.secrets) return {} try { return JSON.parse(decrypt(row.secrets)) } catch { return {} } @@ -76,6 +87,9 @@ export async function integrationRoutes(app) { `, [slug, schema.name, config, secretsEnc, enabled]) const { rows: [updated] } = await pool.query('SELECT * FROM integrations WHERE slug = $1', [slug]) + + if (slug === 'workforce' || slug === 'smtp') bustAuthCache() + return maskRow(updated) })