crosscode: scripts/products/website.sh (ports 5300/3300, uploads in the export), crosscode add <church> website (needs Accounts; www.<address> or the Cross Code address), one install_app for Accounts and the Website, env template copy, bats tests. Backend: Hub client (protocol v2, product website), crosscode.link/1 with automatic connect to the church's Accounts, sign-in through @crosscode/auth-client with the Website's own session and roles, the first Owner from HUB_ADMIN_EMAIL (verified), 2FA for Owners and Admins, back-channel logout, Accounts' user.* calls, and the church export. Frontend: admin sign-in/out and the sign-in problem page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
785 B
TypeScript
20 lines
785 B
TypeScript
/**
|
|
* The admin audit log (who changed what, WEBSITE-1.0-PLAN §4). Logging never breaks the
|
|
* action it records.
|
|
*/
|
|
import type { Request } from 'express';
|
|
import type { Ctx } from '../context.js';
|
|
|
|
export function clientIp(req: Request | undefined): string | null {
|
|
return req ? (req.ip ?? req.socket?.remoteAddress ?? null) : null;
|
|
}
|
|
|
|
export async function audit(ctx: Ctx, entry: { actorId: string | null; actorRole: string; action: string; targetType: string; targetId?: string | null; metadata?: object; ip?: string | null }) {
|
|
try {
|
|
await ctx.db.auditLog.create({ data: { ...entry, targetId: entry.targetId ?? null, metadata: (entry.metadata ?? undefined) as never, ip: entry.ip ?? null } });
|
|
} catch (e) {
|
|
console.error('[audit]', (e as Error).message);
|
|
}
|
|
}
|
|
|