Cross Events 3.0.0: sign-in through the church's Accounts

Settings -> Sign-in: check, move (everyone into Accounts with their password
hashes and authenticator apps, count/hash check, then switch) and undo for
14 days. Sign-in through auth-client with a one-time handoff to Events' own
token; staff roles stepped up to mfa; sign-out and back-channel logout;
user.updated/export/deleted; admin 2FA reset, unlock and profile changes via
Accounts; /login, /register, /forgot-password forward once moved; Events'
own sign-in endpoints answer SIGN_IN_MOVED. User.accountId, AccountsSignIn.

npm run test:accounts runs Events' code against the real Accounts app (11
tests); 5 new Jest tests. MIGRATING-TO-3.md, plan "Changes while building".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 14:10:30 +02:00
co-authored by Claude Opus 5.5
parent 56cbef1d9b
commit c627c61de1
49 changed files with 4094 additions and 245 deletions
+36 -2
View File
@@ -52,8 +52,9 @@ connected before its Events can move.
12. [What changes in each repo](#11-what-changes-in-each-repo)
13. [Testing](#12-testing)
14. [Releasing and rolling it out](#13-releasing-and-rolling-it-out)
15. [Decisions](#decisions)
16. [Still open](#still-open)
15. [Changes while building](#changes-while-building)
16. [Decisions](#decisions)
17. [Still open](#still-open)
---
@@ -418,6 +419,39 @@ only for a connected product:
login events, Events' audit log) → after 14 days the Undo window closes and the old secrets are
cleared. **The demo site first, then Hope Family Church**, then the rest.
## Changes while building
1. **One request schema for product → Accounts:** `crosscode.identity-request/1` at
`POST /api/accounts/v1/requests` carries both `import.*` and `people.*` (contracts 1.8.0), so
`crosscode.identity/1` (Accounts → product) is unchanged. The `people.*` names: `ensure`,
`update`, `resetTwoFactor`, `unlock`, `setActive`, `newsOff`. A request id seen before gets its
first answer.
2. **`import.finish` hashes the subs Accounts gave back**, not the Events ids, so people linked to an
account they already had count too. Accounts compares it with the people it holds as moved from
that product (`ProductPerson`).
3. **Notice versions are shifted by one:** Accounts' built-in notice is version 1, Events' is 0, so
Events' version *n* is Accounts' *n + 1* (acceptances too). "Use Cross Events' notice" when
Accounts already has its own isn't offered yet: the admin keeps Accounts' notice, or removes it
in Accounts first.
4. **The setup wizard still makes a local first admin** (§9 is not built): a new install starts in
`local`, and its admin moves sign-in once Accounts is connected (a one-person move takes seconds).
That avoids a setup that depends on Accounts being connected first. Signing in through Accounts
from the wizard can come with Hub 2.5.0's automatic Connect.
5. **People who never activated** (`isActive` false and never signed in) move as active accounts
without a password: Accounts' "Forgot your password?" sets one. Everyone else who is deactivated
moves as deactivated.
6. **`/login` forwards instead of a new `signInHref` in every link:** every existing
`/login?redirect=` link (and `useRequireAuth`, which now passes the current page) goes through it,
so the 49 files that link to `/login` didn't change.
7. **Events' own sign-in endpoints answer 409 `SIGN_IN_MOVED`** from one guard
(`src/accounts/guard.ts`) rather than in each controller. The guard only passes an admin's change
of someone's name, email or phone to Accounts for a valid, current admin token with its second step.
8. **The `auth-client` loader** uses a real dynamic `import()` (`src/accounts/client.ts`), since the
backend compiles to CommonJS and deploys still allow Node 20.
9. **Tests:** `npm run test:accounts` runs Events' own code (move, sign-in, sign-out, back-channel
logout, `user.updated`, Undo) against the whole Accounts app on real ports, each with an in-memory
database (11 tests). `user.export` and `user.deleted` are Jest tests (`tests/accountsCalls.test.ts`).
## Decisions
Confirmed by Joshua on 2026-11-19, all as proposed.