Merge claude/login-page-whitelabel-616f3d: the panel's sign-in look (whiteLabel.signIn), the client's logo, hardened brand image fetch

Conflicts kept both sides: the 2FA texts (twoFactorBusy from A, twoFactorCodeDigit here), the reference index rows,
and the e2e:built line (closed doors from C and the sign-in look here). routes.snapshot.json judges the new public
GET /api/ipal/admin-language.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-26 22:04:30 +01:00
co-authored by Claude Opus 5.5
126 changed files with 2283 additions and 46 deletions
+61 -1
View File
@@ -20,6 +20,10 @@ import { ROLE_HIERARCHY } from './modules/access/types.js'
import { applyAdminI18n } from './modules/admin-i18n/apply.js'
import { buildAdminImageEndpoints } from './modules/branding/adminImages.js'
import { buildAdminMeta, DEFAULT_AGENCY, syncAdminMeta } from './modules/branding/adminMeta.js'
import { SIGN_IN_LOOK } from './modules/branding/signIn/brand.js'
import { lockBrandFields } from './modules/branding/signIn/brandAccess.js'
import { buildAdminLanguageEndpoint } from './modules/branding/signIn/languageEndpoint.js'
import { resolveSignInLook } from './modules/branding/signIn/options.js'
import { buildConsentLogCollection, buildConsentLogEndpoint } from './modules/consent/consentLog.js'
import { addCookieScannerTabs } from './modules/consent/scanner/adminTabs.js'
import { buildCookieApprovalEndpoints, COOKIE_APPROVAL_VIEW_PATH } from './modules/consent/scanner/approval.js'
@@ -200,6 +204,8 @@ export const iapl = (options: IaplOptions): Plugin => {
let twoFactorCollection: null | string = null
/** Set when the committed admin import map lacks the 2FA view wrapper (production). */
let staleImportMap: null | string = null
/** `whiteLabel.signIn.allScreens` asked for a provider the import map on disk lacks: left out, said in the log. */
let staleSignInLook: null | string = null
/** This config's entry in the staff registry until a Payload instance takes it over. */
const staffToken = {}
/**
@@ -525,7 +531,10 @@ export const iapl = (options: IaplOptions): Plugin => {
if (wl.settingsSlug) {serverProps.settingsSlug = wl.settingsSlug}
if (wl.nameField) {serverProps.nameField = wl.nameField}
if (wl.inlineImages === false) {serverProps.inlineImages = false}
const logoProps = { ...serverProps, ...(wl.logoField ? { imageField: wl.logoField } : {}) }
// The sign-in look (on by default with whiteLabel; `signIn: false` keeps Payload's screens). The logo
// component and the 2FA wrapper print the panel: both are in the import map of every site already.
const look = resolveSignInLook(wl)
const logoProps = { ...serverProps, ...(wl.logoField ? { imageField: wl.logoField } : {}), ...(look ? { signIn: look.props } : {}) }
const iconProps = { ...serverProps, ...(wl.iconField ? { imageField: wl.iconField } : {}) }
// Vendor credit ("Technology support: Intecion.com") under the nav — on by
@@ -573,6 +582,44 @@ export const iapl = (options: IaplOptions): Plugin => {
? { meta: { ...(config.admin?.meta ?? {}), titleSuffix: wl.titleSuffix } }
: {}),
}
if (look) {
// In front of the 2FA screens: IAPL's own wrapper gets the look (a project's own screens are left alone).
const views = (config.admin?.components?.views ?? {}) as Record<string, { Component?: unknown }>
const withLook = Object.fromEntries(
Object.entries(views).map(([key, view]) => {
const component = view?.Component as { path?: string; serverProps?: object } | undefined
return component && typeof component === 'object' && component.path === SAFE_TOTP_VIEW
? [key, { ...view, Component: { ...component, serverProps: { ...component.serverProps, iaplSignIn: look.props } } }]
: [key, view]
}),
)
if (Object.keys(withLook).length) {
config.admin = { ...config.admin, components: { ...config.admin?.components, views: withLook as never } }
}
// The language links of the panel: a public endpoint that writes Payload's own language cookie.
if (look.props.languages !== false) {
config.endpoints = [...(config.endpoints ?? []), buildAdminLanguageEndpoint()]
}
// Every other minimal screen (forgot / reset password, first user, logout): one provider, one new
// import-map entry — asked for with `allScreens`. A provider the import map lacks renders NOTHING,
// the whole panel included, so a production start checks the file on disk and leaves the provider
// out when it is not there: the login and 2FA screens keep the look, the log says what to run.
if (look.allScreens) {
const stale = process.env.NODE_ENV === 'production' ? await missingImportMapEntries(config, [SIGN_IN_LOOK]) : { file: null, missing: [] }
if (stale.missing.length) {
staleSignInLook = `${SIGN_IN_LOOK} was not found in ${stale.file}`
} else {
config.admin = {
...config.admin,
components: {
...config.admin?.components,
providers: [...(config.admin?.components?.providers ?? []), { path: SIGN_IN_LOOK, serverProps: { look: look.props } }],
},
}
}
}
}
}
// --- admin <head>: link previews + noindex (default on) ---
@@ -729,6 +776,13 @@ export const iapl = (options: IaplOptions): Plugin => {
: pluginGlobals
// The project's globalOverrides win (access, admin, hooks merged; a function = full control).
config.globals = [...(config.globals ?? []), ...applyGlobalOverrides(withRevalidate, options.globalOverrides)]
// The brand the sign-in screens show (name, logo, icon) is changed by admins only — with the sign-in look,
// unless the project says `brandAccess: 'editor'`; without the look only when it says `'admin'`.
const brandWl = options.whiteLabel === true ? {} : options.whiteLabel
if (brandWl && (brandWl.brandAccess === 'admin' || (brandWl.brandAccess !== 'editor' && resolveSignInLook(brandWl)))) {
const wl = brandWl
config.globals = lockBrandFields(config.globals, wl.settingsSlug ?? 'site-settings', [wl.nameField ?? 'siteName', wl.logoField ?? 'logo', wl.iconField ?? 'favicon'])
}
// A new site name refreshes the panel's link preview texts.
if (adminMeta) {
@@ -958,6 +1012,12 @@ export const iapl = (options: IaplOptions): Plugin => {
if (graphAvailable() && options.mail?.graphDeprecationWarning !== false) {payload.logger.warn(GRAPH_DEPRECATION_NOTICE)}
// Payload's dev reload swaps `payload.config` and runs no onInit: adopt the new config at once.
watchPayloadConfig(payload, adoptConfig)
if (staleSignInLook) {
payload.logger.error(
`[iapl] The sign-in look covers only the login and 2FA screens: ${staleSignInLook}. Run "pnpm payload generate:importmap", ` +
'commit importMap.js, rebuild and redeploy (docs/white-label.md "Every sign-in screen").',
)
}
if (staleImportMap) {
payload.logger.error(
`[iapl] The admin import map may be out of date: ${staleImportMap}. If the 2FA setup and verify screens are ` +