app: the admin's backend: members and roles, jobs, logs, the setup checklist (APP-1.0-PLAN §10)
Members and roles: members searched by name or email with what they hold; roles given and taken by an Owner or Church admin (only an Owner makes or changes an Owner, nobody changes their own), or someone added by email with a role through Accounts' people.ensure. Background jobs: each job's switch and schedule (winning over the .env) and Run now. The audit log and the access log in plain words, 100 at a time. The dashboard's overview adds the setup checklist (the church's details and icon, the wall's rules, prayer coordinators, a first announcement, sharing the App), this week's coverage and gaps, what waits for the prayer team and recent changes, each for the roles it's about; Share the App marks the checklist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* tested against Accounts' provider in apps/accounts/backend/tests/authClient.test.ts), linked to a
|
||||
* church's Accounts and registered with the Hub, and a clock the tests can move.
|
||||
*/
|
||||
import crypto from 'node:crypto';
|
||||
import { IDENTITY_REQUEST_SCHEMA, type IdentityClaims } from '@crosscode/contracts';
|
||||
import { sealLinkValue } from '@crosscode/contracts/signing';
|
||||
import type { AuthClientModule } from '../../src/auth/accounts.js';
|
||||
@@ -27,6 +28,8 @@ export type FakeAccounts = {
|
||||
/** Requests the App sent Accounts (`crosscode.identity-request/1`). */
|
||||
requests: Record<string, unknown>[];
|
||||
/** What `messaging.get` answers: the church's settings in the clear (sealed on the way), or an error. */
|
||||
/** Accounts' accounts by email, for people.ensure. */
|
||||
accountsByEmail: Map<string, string>;
|
||||
messaging: { email: (Omit<Smtp, 'pass'> & { pass: string | null }) | null; whatsapp: Wawp | null } | Error;
|
||||
};
|
||||
|
||||
@@ -107,6 +110,14 @@ function fakeAuthClient(fake: FakeAccounts): AuthClientModule {
|
||||
updatedAt: '2026-11-30T10:00:00.000Z',
|
||||
};
|
||||
}
|
||||
if (input.type === 'people.ensure') {
|
||||
// The same account for the same email, as Accounts does; new ones get a fresh id.
|
||||
const email = String(input.email);
|
||||
const known = fake.accountsByEmail.get(email);
|
||||
const sub = known ?? crypto.randomUUID();
|
||||
fake.accountsByEmail.set(email, sub);
|
||||
return { schema: IDENTITY_REQUEST_SCHEMA, sub, created: !known, emailSent: !known };
|
||||
}
|
||||
return { schema: IDENTITY_REQUEST_SCHEMA, ok: true };
|
||||
},
|
||||
verifyAccountsCall: (raw: Buffer, headers: Record<string, unknown>) => {
|
||||
@@ -126,7 +137,7 @@ export function testClock(start = '2026-12-01T06:00:00Z') {
|
||||
export async function harness(opts: { linked?: boolean; env?: Record<string, string> } = {}) {
|
||||
const db = memoryDb();
|
||||
const clock = testClock();
|
||||
const fake: FakeAccounts = { next: { sub: PASTOR }, started: [], requests: [], messaging: { email: CHURCH_SMTP, whatsapp: CHURCH_WAWP } };
|
||||
const fake: FakeAccounts = { next: { sub: PASTOR }, started: [], requests: [], accountsByEmail: new Map(), messaging: { email: CHURCH_SMTP, whatsapp: CHURCH_WAWP } };
|
||||
const transport = new MemoryTransport();
|
||||
const config = loadConfig({ APP_URL: SITE, HUB_ADMIN_EMAIL: ADMIN_EMAIL.toUpperCase(), ...opts.env });
|
||||
const ctx = createCtx(config, db as unknown as Db, { authClient: async () => fakeAuthClient(fake), now: clock.now, transport });
|
||||
|
||||
Reference in New Issue
Block a user