2FA screens: the brand image loads for a session that still owes its code; browser spec checks it
The tab icon endpoint answers with the image itself instead of a redirect to the media file, and the logo components hand a session that owes its 2FA code (or has not set 2FA up) the picture fetched without credentials, as an anonymous visitor gets it. Who can read media is unchanged; when the file is not public or is larger than 512 KB the site name is used. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
2aaaaa115a
commit
5d44ac3135
@@ -2,6 +2,8 @@ import type { Payload } from 'payload'
|
||||
|
||||
import { ipalT } from '../admin-i18n/t.js'
|
||||
import { settingsTexts } from '../admin-i18n/texts/settings.js'
|
||||
import { secondFactorPassed } from '../security/totp/secondFactor.js'
|
||||
import { publicImageDataUri, siteOrigin } from './publicImage.js'
|
||||
|
||||
/**
|
||||
* White-label admin branding: the Payload admin panel's logo (login + nav) and
|
||||
@@ -33,6 +35,8 @@ type BrandingProps = {
|
||||
payload?: Payload
|
||||
/** SiteSettings global slug. Default 'site-settings'. */
|
||||
settingsSlug?: string
|
||||
/** Injected by Payload into admin server components — the account looking at the panel. */
|
||||
user?: null | Record<string, unknown>
|
||||
}
|
||||
|
||||
type MediaLike = { url?: null | string } | null | undefined
|
||||
@@ -70,6 +74,13 @@ async function loadBranding(
|
||||
const image = settings[imageField] as MediaLike
|
||||
const url =
|
||||
image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null
|
||||
// A session that still owes its 2FA code (or has not set 2FA up) is refused `media` like every
|
||||
// other collection, so the browser would show a broken image on the verify / setup screens.
|
||||
// Give it the picture itself, fetched as an anonymous visitor would get it; when that fails
|
||||
// (media is not public), the site name is shown instead.
|
||||
if (url && props.user && !secondFactorPassed({ payload, user: props.user })) {
|
||||
return { name, url: await publicImageDataUri(url, siteOrigin(payload.config.serverURL)) }
|
||||
}
|
||||
return { name, url }
|
||||
} catch (error) {
|
||||
console.warn('[ipal] admin branding: falling back to Payload default:', error)
|
||||
|
||||
Reference in New Issue
Block a user