|
| 1 | +--- |
| 2 | +"@objectstack/plugin-auth": patch |
| 3 | +--- |
| 4 | + |
| 5 | +fix(plugin-auth): the mail transport, brand and locale bindings no longer depend on `registerRoutes` |
| 6 | + |
| 7 | +`AuthPlugin` bound five things to the live kernel on `kernel:ready` — the |
| 8 | +outbound mail transport (`setEmailService`), the SMS transport |
| 9 | +(`setSmsService`), the deployment email locale (`setDefaultEmailLocale`), the |
| 10 | +brand name (`setAppName`) and the SMS locale (`setDefaultSmsLocale`) — from |
| 11 | +inside the same hook that mounts `/api/v1/auth/*`, and that hook was gated on |
| 12 | +`registerRoutes`. |
| 13 | + |
| 14 | +`registerRoutes` answers a transport-mounting question: should this plugin put |
| 15 | +its own routes on the kernel's `http-server`. The bindings are service |
| 16 | +composition, and they are true of an embedding regardless of who serves the |
| 17 | +routes. So an embedding that serves auth routes itself — the whole point of |
| 18 | +`registerRoutes: false` — came up with no mail transport, no locale on either |
| 19 | +channel and no brand binding. Silently: the `logger.info` lines that report the |
| 20 | +wiring were inside the same skipped block, and the `localization` settings |
| 21 | +namespace was not even read. One visible consequence was that the workspace |
| 22 | +language could not reach auth mail on such a host at all, and |
| 23 | +`/api/v1/auth/config` answered `requireEmailVerification: false` because |
| 24 | +`resolveRequireEmailVerification()` saw no transport. |
| 25 | + |
| 26 | +The composition block now registers as its own unconditional |
| 27 | +`ctx.hook('kernel:ready', …)` — the shape the sibling diagnosis and dev-seed |
| 28 | +hooks in this plugin already use — placed before the route hook so a routing |
| 29 | +host keeps the ordering the single combined hook gave it. |
| 30 | + |
| 31 | +Route registration itself stays gated: a `registerRoutes: false` kernel still |
| 32 | +mounts no auth routes. |
| 33 | + |
| 34 | +**Behaviour change for `registerRoutes: false` embeddings.** They now resolve |
| 35 | +the `email`, `sms`, `i18n` and `settings` services at `kernel:ready`, apply |
| 36 | +`branding.workspace_name` and `localization.locale` (subscribing to both), seed |
| 37 | +the built-in auth SMS templates when phone sign-in is enabled, and emit the |
| 38 | +four wiring `info` lines. Hosts that had compensated by wiring these by hand |
| 39 | +should expect the plugin's own binding to run as well; both paths are |
| 40 | +idempotent setters, and an explicit workspace setting keeps outranking a |
| 41 | +manifest default exactly as it does on a routing host. Nothing changes for a |
| 42 | +host that leaves `registerRoutes` at its default. |
0 commit comments