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
@@ -0,0 +1,22 @@
'use client'
import { useEffect } from 'react'
/**
* Names for the boxes of the 2FA code. The package draws one text box per digit without a label, so a screen
* reader announces six unnamed fields. After the page is live each box gets `aria-label` ("Digit 2 of 6") and
* the numeric keyboard on a phone. Attributes only: no value, handler or focus is touched, and a box that
* already has a name keeps it. Rendered by `SafeTotpView` together with the sign-in look.
*/
export function CodeInputNames({ label }: { label: string }) {
useEffect(() => {
const boxes = document.querySelectorAll<HTMLInputElement>('.template-minimal form input[type="text"][maxlength="1"]')
boxes.forEach((box, index) => {
if (!box.hasAttribute('aria-label') && !box.hasAttribute('aria-labelledby')) {
box.setAttribute('aria-label', label.replace('%n', String(index + 1)).replace('%t', String(boxes.length)))
}
if (!box.hasAttribute('inputmode')) {box.setAttribute('inputmode', 'numeric')}
})
}, [label])
return null
}
+35 -2
View File
@@ -4,9 +4,21 @@ import type React from 'react'
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'
import { getFromImportMap } from 'payload/shared'
import type { SignInLookProps } from '../../branding/signIn/brand.js'
import { iaplT } from '../../admin-i18n/t.js'
import { securityTexts } from '../../admin-i18n/texts/security.js'
import { signInProviderActive } from '../../branding/signIn/brand.js'
import { SignInPanel } from '../../branding/signIn/SignInPanel.js'
import { CodeInputNames } from './CodeInputNames.js'
import { safeAdminBack, type SafeBackRule, type TotpViewComponent, totpViewImportKey } from './safeBack.js'
export type SafeTotpViewProps = {
/**
* `whiteLabel.signIn`, set by the plugin: the sign-in panel is printed in front of the 2FA screen when the
* provider (`SignInLook`) does not print it. Not set: the screen as the package draws it.
*/
iaplSignIn?: SignInLookProps
/** `twoFactor.safeBack` as a function: replaces the default rule. */
ipalSafeBack?: SafeBackRule
/** `clientProps` of the view's own registration; passed on to it. */
@@ -42,7 +54,7 @@ const CLIENT_PROPS = ['browseByFolderSlugs', 'clientConfig', 'collectionSlug', '
* `admin.dependencies`.
*/
export function SafeTotpView(props: SafeTotpViewProps): React.ReactNode {
const { ipalSafeBack, ipalTotpClientProps, ipalTotpView, ...rest } = props
const { iaplSignIn, ipalSafeBack, ipalTotpClientProps, ipalTotpView, ...rest } = props
const config = props.initPageResult?.req?.payload?.config ?? props.payload?.config
const query = (props.searchParams ?? {}) as Record<string, unknown>
const back = (ipalSafeBack ?? safeAdminBack)(typeof query.back === 'string' ? query.back : undefined, {
@@ -61,10 +73,31 @@ export function SafeTotpView(props: SafeTotpViewProps): React.ReactNode {
for (const key of CLIENT_PROPS) {
if (key in rest) {clientProps[key] = (rest as Record<string, unknown>)[key]}
}
return RenderServerComponent({
const view = RenderServerComponent({
clientProps,
Component: ipalTotpView,
importMap: props.importMap,
serverProps: { ...rest, searchParams },
})
const req = props.initPageResult?.req
const payload = req?.payload ?? props.payload
// The look only: the panel is a sibling in front of the screen, the screen itself is rendered as above.
if (!iaplSignIn) {return view}
const i18n = (req?.i18n ?? props.i18n) as { t: (key: never, vars?: Record<string, unknown>) => string } | undefined
const digit = i18n ? iaplT(i18n.t, 'twoFactorCodeDigit', { n: '%n', total: '%t' }) : securityTexts.en.twoFactorCodeDigit.replace('{{n}}', '%n').replace('{{total}}', '%t')
return (
<>
{signInProviderActive(payload) ? null : (
<SignInPanel
i18n={i18n as never}
locale={(props.initPageResult?.locale ?? props.locale) as never}
look={iaplSignIn}
payload={payload}
user={(req?.user ?? props.user) as never}
/>
)}
{view}
<CodeInputNames label={digit} />
</>
)
}