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
@@ -0,0 +1,41 @@
-- 3.0.0: signing in through the church's Accounts (docs/EVENTS-3.0-PLAN.md).
ALTER TYPE "AdminAuditAction" ADD VALUE 'sign_in_move_started';
ALTER TYPE "AdminAuditAction" ADD VALUE 'sign_in_move_finished';
ALTER TYPE "AdminAuditAction" ADD VALUE 'sign_in_move_failed';
ALTER TYPE "AdminAuditAction" ADD VALUE 'sign_in_move_undone';
ALTER TYPE "AdminAuditAction" ADD VALUE 'sign_in_secrets_cleared';
ALTER TYPE "AdminAuditAction" ADD VALUE 'account_changed_in_accounts';
-- AlterTable
ALTER TABLE "User" ADD COLUMN "accountId" TEXT;
-- CreateIndex
CREATE UNIQUE INDEX "User_accountId_key" ON "User"("accountId");
-- CreateTable
CREATE TABLE "AccountsSignIn" (
"id" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"codeHash" TEXT,
"codeExpires" TIMESTAMP(3),
"codeUsedAt" TIMESTAMP(3),
"returnTo" TEXT NOT NULL,
"idToken" TEXT,
"sid" TEXT,
"mfa" BOOLEAN NOT NULL DEFAULT false,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "AccountsSignIn_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "AccountsSignIn_codeHash_key" ON "AccountsSignIn"("codeHash");
-- CreateIndex
CREATE INDEX "AccountsSignIn_userId_idx" ON "AccountsSignIn"("userId");
-- CreateIndex
CREATE INDEX "AccountsSignIn_createdAt_idx" ON "AccountsSignIn"("createdAt");
-- AddForeignKey
ALTER TABLE "AccountsSignIn" ADD CONSTRAINT "AccountsSignIn_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;