Sign-in look: the client's logo or the site's name on a dark panel beside the form (whiteLabel.signIn)
On by default with whiteLabel. The login screen and the 2FA screens get the look through AdminLogo and SafeTotpView, which every site already has in its import map: an upgrade needs no edit. allScreens adds one provider (SignInLook) for forgot / reset password, first user and logout; a production start leaves it out when the import map on disk lacks it. Logo and name come from Site settings: no new field, no migration. Language links through GET /api/ipal/admin-language (Payload's own cookie, back to an admin path only). Options: accent, logoMadeFor, languages, svgLogo; whiteLabel.brandAccess 'admin'. The 2FA code boxes get names for screen readers. Reference site and starter: allScreens on. Docs, agent guide, skills, tests. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
e821d52d19
commit
b6c91a3a11
+59
-1
@@ -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'
|
||||
@@ -197,6 +201,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 = {}
|
||||
/**
|
||||
@@ -522,7 +528,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
|
||||
@@ -570,6 +579,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) ---
|
||||
@@ -726,6 +773,11 @@ 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)]
|
||||
// `whiteLabel.brandAccess: 'admin'`: the brand the sign-in screens show is changed by admins only.
|
||||
if (options.whiteLabel && options.whiteLabel !== true && options.whiteLabel.brandAccess === 'admin') {
|
||||
const wl = options.whiteLabel
|
||||
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) {
|
||||
@@ -955,6 +1007,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 ` +
|
||||
|
||||
Reference in New Issue
Block a user