Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(auth): clarify identity provider sign-in failures (#9299)
gbirmandb5c9adbbfa6
diff --git a/infra/stacks/fusionauth-instance/README.md b/infra/stacks/fusionauth-instance/README.mdindex b4d23e3df0..80581fb772 100644--- a/infra/stacks/fusionauth-instance/README.md+++ b/infra/stacks/fusionauth-instance/README.md@@ -34,6 +34,29 @@ password: macroIsGreat!api-key: bf69486b-4733-4954-a44e-2e1b5f2c8a91```+## Sign-in validation error message++`update-theme-message.ts` sets `[IdentityProviderValidationException]` to+conditional sign-in recovery guidance. It replaces or adds this one single-line+entry, preserving the rest of `defaultMessages`. The PATCH sends no templates+or other theme settings. Authentication and reconciliation are unchanged.+The updater and Pulumi configuration share the theme IDs in `theme-ids.ts`.+Before applying, save any existing value of this entry for rollback.++```sh+# From this directory; uses the stack's existing Pulumi host and API key.+bun update-theme-message.ts dev # read-only preview (or use prod)+bun update-theme-message.ts dev --apply # only after authorization+```++Merging or deploying this stack does **not** apply the copy. Run the updater+separately for the authorized environment. A JSON Patch `test` prevents a stale+read from overwriting another message edit; preview again after a conflict.+For rollback, restore the prior value of this property in the theme editor,+or remove it if it was previously inherited.++Use Biome from `nix develop` to match infrastructure CI.+# TODO- [ ] configure idps- [ ] sync prod with pulumi stackdiff --git a/infra/stacks/fusionauth-instance/constants.ts b/infra/stacks/fusionauth-instance/constants.tsindex 7b165108bf..e529839ff3 100644--- a/infra/stacks/fusionauth-instance/constants.ts+++ b/infra/stacks/fusionauth-instance/constants.ts@@ -2,6 +2,7 @@ import { config, stack } from '../../packages/shared';import * as aws from '@pulumi/aws';import * as pulumi from '@pulumi/pulumi';import { Provider } from 'pulumi-fusionauth';+import { FUSIONAUTH_THEME_IDS } from './theme-ids';// The id of the default tenantexport const DEFAULT_FUSIONAUTH_TENANT_ID =@@ -89,8 +90,4 @@ export const fusionAuthProvider = new Provider('fusion-auth-provider', {The fusionauth custom theme. This is just a theme with a custom oauth redirect*/export const FUSIONAUTH_THEME_ID =- stack === 'prod'- ? 'e486f9ac-e63f-4549-8244-ee8ed641f8a0'- : stack === 'dev'- ? '87cf78dd-03ba-478a-9211-3da0cdba9c3f'- : undefined;+ stack === 'prod' || stack === 'dev' ? FUSIONAUTH_THEME_IDS[stack] : undefined;diff --git a/infra/stacks/fusionauth-instance/theme-ids.ts b/infra/stacks/fusionauth-instance/theme-ids.tsnew file mode 100644index 0000000000..defb337a32--- /dev/null+++ b/infra/stacks/fusionauth-instance/theme-ids.ts@@ -0,0 +1,4 @@+export const FUSIONAUTH_THEME_IDS = {+ prod: 'e486f9ac-e63f-4549-8244-ee8ed641f8a0',+ dev: '87cf78dd-03ba-478a-9211-3da0cdba9c3f',+};diff --git a/infra/stacks/fusionauth-instance/update-theme-message.ts b/infra/stacks/fusionauth-instance/update-theme-message.tsnew file mode 100644index 0000000000..74664b4e00--- /dev/null+++ b/infra/stacks/fusionauth-instance/update-theme-message.ts@@ -0,0 +1,66 @@+import { execFileSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { FUSIONAUTH_THEME_IDS } from './theme-ids';++const [stack, mode, ...extra] = process.argv.slice(2);+if (+ (stack !== 'dev' && stack !== 'prod') ||+ (mode !== undefined && mode !== '--apply') ||+ extra.length > 0+) {+ throw new Error('Usage: bun update-theme-message.ts <dev|prod> [--apply]');+}++const config = (key: string) =>+ execFileSync(+ 'pulumi',+ ['config', 'get', `fusionauth:${key}`, '--stack', `macro-inc/${stack}`],+ {+ cwd: fileURLToPath(new URL('.', import.meta.url)),+ encoding: 'utf8',+ stdio: ['ignore', 'pipe', 'pipe'],+ }+ ).trim();++const entry =+ "[IdentityProviderValidationException]=We couldn't complete sign-in. If this Gmail address is connected as an additional inbox, sign in with the email you originally used to create your Macro account. Return to Macro and choose Continue with email, or contact support.";+const url = new URL(+ `/api/theme/${FUSIONAUTH_THEME_IDS[stack]}`,+ config('host')+);+const headers = { Authorization: config('apiKey') };+const response = await fetch(url, { headers, redirect: 'error' });+if (!response.ok) throw new Error(`Theme read failed: HTTP ${response.status}`);++const messages: string = JSON.parse(await response.text()).theme+ .defaultMessages;+const existingEntry = /^\[IdentityProviderValidationException\]=[^\r\n]*/m;+const updated = existingEntry.test(messages)+ ? messages.replace(existingEntry, entry)+ : `${messages}${messages.endsWith('\n') ? '' : '\n'}${entry}\n`;++console.log(`${stack}: ${entry}`);+if (updated === messages) {+ console.log('Already up to date.');+} else if (mode !== '--apply') {+ console.log(+ 'Preview only. Use --apply after authorization to update the theme.'+ );+} else {+ const patch = await fetch(url, {+ method: 'PATCH',+ redirect: 'error',+ headers: { ...headers, 'Content-Type': 'application/json-patch+json' },+ // Reject a stale read rather than overwrite another message edit.+ body: JSON.stringify([+ { op: 'test', path: '/theme/defaultMessages', value: messages },+ { op: 'replace', path: '/theme/defaultMessages', value: updated },+ ]),+ });+ if (!patch.ok) {+ throw new Error(+ `Theme patch failed: HTTP ${patch.status}; preview again before retrying`+ );+ }+ console.log('Theme message updated.');+}