Accounts sign-in looks like the church's site; Events sends its logo and colours
- @crosscode/ui: Shell with the church's colour wash, logo (or its initial) and name, footer; Card edged in the church's colour; Heading with an icon tile. Icons on every sign-in step. - contracts 1.9.0: churchLookSchema (logo, accent colour) in import.begin; church.branding request. Accounts fills (move) or replaces (button) the church profile's name, logo and colours. - Events 3.1.0: src/accounts/look.ts (logo as a full address), sent with a move; Settings -> Sign-in "Use this site's logo and colours". Tests: Accounts 55, contracts 218, Events 774, test:accounts 16. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { authMode } from '../../accounts/mode';
|
||||
import { check, move, MoveError, status, undo } from '../../accounts/move';
|
||||
import { accounts, accountsLink, AccountsUnavailable } from '../../accounts/client';
|
||||
import { accountsMessaging, eventsMessaging, sendToAccounts } from '../../accounts/messaging';
|
||||
import { churchLook } from '../../accounts/look';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
|
||||
const prisma = require('../../config/db');
|
||||
@@ -231,6 +232,23 @@ export const signInMessagingSave = defineRoute({
|
||||
},
|
||||
});
|
||||
|
||||
export const signInLook = defineRoute({
|
||||
method: 'post',
|
||||
path: '/settings/sign-in/look',
|
||||
tag: 'Accounts',
|
||||
summary: "Use this site's logo and colours on the church's sign-in pages",
|
||||
description: "Sends this site's name, logo and colours to the church's Accounts, replacing what its sign-in pages had.",
|
||||
access: 'admin',
|
||||
response: single(z.object({ name: z.string().nullable(), logoUrl: z.string().nullable(), primaryColour: z.string().nullable(), accentColour: z.string().nullable() })),
|
||||
async handler({ user, req }) {
|
||||
const look = await churchLook();
|
||||
const actor = (await prisma.user.findUnique({ where: { id: user!.id }, select: { accountId: true } }))?.accountId ?? null;
|
||||
await (await accounts().catch(asApiError)).request({ type: 'church.branding', actor, church: look, overwrite: true }).catch(asApiError);
|
||||
await logAdminAction({ actorId: user!.id, actorRole: user!.role, action: 'account_changed_in_accounts', targetType: 'setting', targetId: 'accounts_look', metadata: look, ip: getClientIp(req) });
|
||||
return { data: { name: look.name, logoUrl: look.logoUrl ?? null, primaryColour: look.primaryColour, accentColour: look.accentColour ?? null } };
|
||||
},
|
||||
});
|
||||
|
||||
// ─── An admin, for someone's account (sign-in through Accounts) ─────────────
|
||||
|
||||
const idParams = z.object({ id: z.uuid() });
|
||||
|
||||
Reference in New Issue
Block a user