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:
@@ -18,13 +18,13 @@ import { IMPORT_BATCH_MAX, phoneSchema, type ImportPerson, type ImportResult } f
|
||||
import { siteUrl } from '../feed/context';
|
||||
import { accounts, accountsLink, AccountsUnavailable } from './client';
|
||||
import { accountsMessaging } from './messaging';
|
||||
import { churchLook } from './look';
|
||||
import { authMode, CLEARED_KEY, getSetting, MODE_KEY, MOVED_AT_KEY, REPORT_KEY, setSetting, UNDO_DAYS } from './mode';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-require-imports -- CommonJS */
|
||||
const prisma = require('../config/db');
|
||||
const { decrypt } = require('../utils/encryption') as { decrypt(v: string): string };
|
||||
const { logAdminAction } = require('../utils/adminAudit') as { logAdminAction(entry: object): Promise<void> };
|
||||
const { getSettingSync } = require('../utils/settingsCache') as { getSettingSync(k: string, f?: string): string };
|
||||
/* eslint-enable @typescript-eslint/no-require-imports */
|
||||
|
||||
export class MoveError extends Error {
|
||||
@@ -144,11 +144,6 @@ export async function status(): Promise<MoveSummary> {
|
||||
};
|
||||
}
|
||||
|
||||
function church() {
|
||||
const name = getSettingSync('org_name', '') || getSettingSync('site_name', '') || null;
|
||||
const colour = getSettingSync('primary_color', '') || getSettingSync('brand_color', '');
|
||||
return { name: name ? name.slice(0, 200) : null, primaryColour: /^#[0-9a-fA-F]{6}$/.test(colour) ? colour : null };
|
||||
}
|
||||
|
||||
export type CheckResult = {
|
||||
accountsVersion: string;
|
||||
@@ -177,7 +172,7 @@ async function connected() {
|
||||
/** The dry run: nothing is written, here or in Accounts. */
|
||||
export async function check(): Promise<CheckResult> {
|
||||
const auth = await connected();
|
||||
const begin = await auth.request<{ noticesTaken: boolean; accountsNoticeVersions: number[]; accountsVersion: string }>({ type: 'import.begin', actor: null, check: true, notices: [], church: church() });
|
||||
const begin = await auth.request<{ noticesTaken: boolean; accountsNoticeVersions: number[]; accountsVersion: string }>({ type: 'import.begin', actor: null, check: true, notices: [], church: await churchLook() });
|
||||
if (!versionAtLeast(begin.accountsVersion, MIN_ACCOUNTS)) {
|
||||
throw new MoveError(`The church's Accounts is version ${begin.accountsVersion}; moving sign-in needs 1.1.0 or later. Update Accounts first.`, 'ACCOUNTS_TOO_OLD');
|
||||
}
|
||||
@@ -286,7 +281,7 @@ export async function move(opts: { actor: { id: string; role: string; name?: str
|
||||
try {
|
||||
const eventsNotices = await notices();
|
||||
const begin = await auth.request<{ noticesTaken: boolean; accountsVersion: string }>({
|
||||
type: 'import.begin', actor: opts.actor.id, check: false, notices: opts.keepAccountsNotices ? [] : eventsNotices, church: church(),
|
||||
type: 'import.begin', actor: opts.actor.id, check: false, notices: opts.keepAccountsNotices ? [] : eventsNotices, church: await churchLook(),
|
||||
});
|
||||
begun = true;
|
||||
if (!versionAtLeast(begin.accountsVersion, MIN_ACCOUNTS)) throw new MoveError(`The church's Accounts is version ${begin.accountsVersion}; moving sign-in needs 1.1.0 or later.`, 'ACCOUNTS_TOO_OLD');
|
||||
|
||||
Reference in New Issue
Block a user