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 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-08 11:57:44 +00:00
parent 71650ed904
commit 558cce44fa

View file

@ -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)
})