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
@@ -64,6 +64,13 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
| `whiteLabel.logoField` / `iconField` / `nameField` | `'logo'` / `'favicon'` / `'siteName'` | fields in Site settings | any upload/text field |
|
||||
| `whiteLabel.titleSuffix` | none | `admin.meta.titleSuffix` (tab title) | — |
|
||||
| `whiteLabel.credit` | on | `IntecionCredit` in `afterLogin` and `afterNavLinks`: "Technology support: Intecion.com" (en/pl, from `agency`) | `false`; `{ text, url }` overrides |
|
||||
| `whiteLabel.signIn` | on (with `whiteLabel`) | the sign-in look: a dark panel with the client's logo (Site settings → Logo, on a white plate) or the site's name beside the form, "Administration panel", language links; both themes, a band above the form on a phone. Login, the 2FA screens and e-mail verification get it through `AdminLogo` / `SafeTotpView` (already in the import map: an upgrade needs no edit). No env var, no new field, no migration | `false` = Payload's own screens |
|
||||
| `whiteLabel.signIn.allScreens` | `false` (the starter writes `true`) | the look on forgot / reset password, create first user, logout and "unauthorized" too: adds the provider `SignInLook` — ONE new import-map entry, run `pnpm payload generate:importmap`. Production start: when `importMap.js` on disk lacks it, the provider is left out and the log says `[iapl] The sign-in look covers only the login and 2FA screens …` | `true` |
|
||||
| `whiteLabel.signIn.accent` | `#0070c0` | hex colour of the button, links and focus ring (anything that is not a hex colour is ignored); or CSS variables `--iapl-signin-*` on `:root` in the admin's `custom.scss` | `'#0b6e4f'` |
|
||||
| `whiteLabel.signIn.logoMadeFor` | `'light'` | `'dark'` = a logo drawn for dark grounds: no white plate | — |
|
||||
| `whiteLabel.signIn.languages` | shown with 2+ admin languages | links on the panel; `GET /api/ipal/admin-language?lng=<code>` writes Payload's `payload-lng` cookie and redirects (303) back to the admin path of the `Referer`; unknown language → 400 | `false` = no links, no endpoint |
|
||||
| `whiteLabel.signIn.svgLogo` | shown as a picture (`<img>` runs no script) | `false` = an SVG logo is not shown on the sign-in screens; the site's name is | — |
|
||||
| `whiteLabel.brandAccess` | `'editor'` (whoever edits Site settings) | `'admin'` = field-level `access.update` on the name, logo and icon fields: only admins change what the sign-in screens show. No schema change | — |
|
||||
| `agency` | `{ name: 'Intecion.com', url: 'https://intecion.com' }` | the credit line, the panel's link description and preview image | `{ name, url }` = another agency; `false` = none anywhere |
|
||||
| `adminMeta` | on (with or without `whiteLabel`) | panel `<head>`: `robots` noindex/nofollow, `titleSuffix` "— <site> \| Panel", `og:site_name` + description from Site settings (refreshed on save), `og:image` `GET /api/ipal/admin-og` (1200×630 from the logo or name), icon `GET /api/ipal/admin-icon` (favicon or initials); no import map step | `false` = Payload defaults; `{ robots, titleSuffix, description, image, icons, language }` (each `false` or your value; `{site}`, `{agency}` placeholders); your own `admin.meta` keys always win. Check: `curl -s $URL/admin/login \| grep -E 'og:\|robots'` (white-label.md) |
|
||||
| `pages` | none | Site settings → **System pages** (page roles) and **Maintenance** tabs | omit → neither tab |
|
||||
@@ -153,6 +160,7 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
|---|---|---|
|
||||
| `AdminLogo`, `AdminIcon` | `graphics.Logo/Icon` | `whiteLabel` |
|
||||
| `IntecionCredit` | `afterLogin`, `afterNavLinks` | `whiteLabel` and `credit !== false` |
|
||||
| `SignInLook` | `providers` (last) | `whiteLabel.signIn.allScreens` — the only entry the sign-in look adds; without it nothing new is needed |
|
||||
| `StatsNavLink`, `StatsView` (`views.ipalStats`, `/stats`), `StatsWidget` (`beforeDashboard`) | nav, view, dashboard | `stats` (`dashboard: false` without the widget) |
|
||||
| `CookieScanButton` | `beforeListTable` of `cookie-review` (with **Check site** when `crawl` is on) | `cookieScanner` |
|
||||
| `CookieReviewTab`, `CookieSiteCheckTab` | `ui` fields in the `cookie-settings` tabs | `cookieScanner` with `adminLayout !== 'separate'` (Site check: `crawl`) |
|
||||
|
||||
@@ -38,6 +38,8 @@ Admin panel components from `@intecion/ipal-kit/admin` — the project does NOT
|
||||
| `TwoFactorResetButton` | `@intecion/ipal-kit/admin` | Client button inside `TwoFactorStatusField`: `POST /api/ipal/two-factor/reset` `{ userId }`, then reloads the view. Props `{ kind: 'reset' \| 'reopen', userId }`. |
|
||||
| `TwoFactorAlert` | `@intecion/ipal-kit/admin` | Server component on the dashboard (`beforeDashboard`), administrators only: accounts without two-step verification and how many are blocked. Wired by the plugin with `twoFactor.requireSetup`; renders nothing when every account has it. |
|
||||
| `IntecionCredit` | `@intecion/ipal-kit/admin` | The line "Technology support: Intecion.com" (admin language; `agency` prop = the name) below the nav and below the login form (`variant: 'nav' \| 'login'`). Injected by the plugin with `whiteLabel`; turn off: `whiteLabel: { credit: false }` or `agency: false`. |
|
||||
| `SignInPanel` | `@intecion/ipal-kit/admin` | Server component: the dark sign-in panel with its stylesheet (`<style>` deduplicated by React) — label, the logo or the site's name from Site settings as a link to the site, language links. Props `look` (`SignInLookProps`) plus what Payload injects (`payload`, `i18n`, `locale`, `user`); `SignInPanelProps`. Hidden by its own CSS on any page that is not Payload's minimal template. `AdminLogo` (prop `signIn`) and `SafeTotpView` (prop `iaplSignIn`) render it when the provider does not. |
|
||||
| `SignInLook` | `@intecion/ipal-kit/admin` | Admin provider (`admin.components.providers`, `serverProps: { look }`; `SignInLookProviderProps`): prints `SignInPanel` on every admin page so that every minimal screen has it. Registered by `whiteLabel: { signIn: { allScreens: true } }`. |
|
||||
| `buildAdminMeta({ agency, apiRoute?, defaultLocale?, meta?, options? })` | `@intecion/ipal-kit` | The `adminMeta` step: static panel meta (robots, preview image, icon) without overwriting keys in `meta`; returns `{ meta, resolved }` |
|
||||
| `adminMetaForSite(site, resolved)`, `syncAdminMeta(payload, resolved, { nameField?, settingsSlug? })` | `@intecion/ipal-kit` | Site-name parts (suffix, description, siteName); `syncAdminMeta` writes them into the live config (onInit + Site settings afterChange, never throws) |
|
||||
| `buildAdminImageEndpoints(resolved, { settingsSlug?, nameField?, logoField?, iconField? })` | `@intecion/ipal-kit` | `GET /api/ipal/admin-og` (1200×630 PNG via `next/og`) and `GET /api/ipal/admin-icon` (the favicon itself, or initials) — already added by `adminMeta` |
|
||||
@@ -623,6 +625,11 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
|
||||
| `countAccountsWithoutTotp(payload, collection, setupWindowMs?)` | `@intecion/ipal-kit` | `{ without, blocked }` — accounts of the 2FA collection without TOTP, and how many are past their window. |
|
||||
| `resolveRequireSetup(option)`, `strictExempt(fn)`, `SETUP_FROM_FIELD`, `DEFAULT_SETUP_WINDOW_HOURS` | `@intecion/ipal-kit` | `twoFactor.requireSetup` → `{ requireSetup, setupWindowMs, exempt? }` as the guard reads it (throws on a `windowHours` that is not a number ≥ 0 or `false`, and on an `async` `exempt`); the wrapper that makes an `exempt` function answer `true` only for exactly `true`; the field name `'totpSetupFrom'`; `72`. |
|
||||
| `fetchPublicImage(url, base)`, `publicImageDataUri(url, base)`, `rasterImageType(bytes)`, `siteOrigin(serverURL)`, `PUBLIC_IMAGE_MAX_BYTES` | `@intecion/ipal-kit` | An image fetched the way an anonymous visitor gets it (no cookies; http(s) only; `image/*`; at most 512 KB, reading stops at the limit) as `{ bytes, type }` or a `data:` address, else `null`. Used for the logo and icon on the 2FA screens. `rasterImageType(bytes)` → the media type of a bitmap by its first bytes (PNG, JPEG, GIF, WebP, ICO, AVIF) or `null` — never trust a claimed type before answering a file's bytes from the site's origin; an SVG gives `null`. |
|
||||
| `resolveSignInLook(whiteLabel)` | `@intecion/ipal-kit` | `whiteLabel` option → `null` (white-label or `signIn` off) or `{ allScreens, props }` (`ResolvedSignInLook`; `props` = `SignInLookProps`, the plain values the components get: `accent`, `imageField`, `inlineImages`, `languages`, `logoMadeFor`, `nameField`, `settingsSlug`, `svgLogo`). Option type: `SignInLookOptions`. |
|
||||
| `loadSignInBrand({ payload, look, locale?, user? })`, `signInName(value, locale?)`, `signInLogo(media, { svgLogo? })`, `fitLogo(width, height, box?)`, `isSvgUpload(media)` | `@intecion/ipal-kit` | What the sign-in panel shows: `{ name, logo }` (`SignInBrand`, `SignInLogo = { src, width?, height? }`) read from Site settings, never throwing; the name as one line of plain text (control characters out, cut at `SIGN_IN_NAME_MAX` = 80); the logo of an upload document (only an `http(s)` or site-relative address; `null` for SVG with `svgLogo: false`), fitted into `SIGN_IN_LOGO_BOX` (240 × 72) without enlarging. A session that owes its 2FA code gets the picture inlined (`publicImageDataUri`) or no logo. |
|
||||
| `signInCss({ accent? })`, `isHexColour(value)`, `SIGN_IN_STYLE_ID` | `@intecion/ipal-kit` | The stylesheet of the sign-in look as a string (no `url()`, no font, no other host; every rule needs `.iapl-signin` on the page), the hex check `accent` must pass, and the `href` of its `<style>` (`'iapl-sign-in'`). |
|
||||
| `languageLinks(config, current)`, `LANGUAGE_NAMES`, `buildAdminLanguageEndpoint()`, `adminPathFromReferer(referer, adminRoute)`, `ADMIN_LANGUAGE_PATH` | `@intecion/ipal-kit` | The panel's languages as links (`LanguageLink[]`: `{ code, name, current, href }`; empty with one language; names in their own language, else the code); the public endpoint `GET /api/ipal/admin-language?lng=` (`'/ipal/admin-language'`) that writes `<cookiePrefix>-lng` for a supported language (else 400) and answers 303 to a path inside the admin route taken from the `Referer` (anything else → the admin root, never another host). |
|
||||
| `signInProviderActive(payload)`, `SIGN_IN_LOOK` | `@intecion/ipal-kit` | Whether the provider `'@intecion/ipal-kit/admin#SignInLook'` is in the config AND in the running import map — `AdminLogo` and `SafeTotpView` print the panel themselves only when it is not. |
|
||||
| `UPLOAD_SECURITY_HEADERS` | `@intecion/ipal-kit` | The two headers of `buildUploadSecurityHeaders` (`Content-Security-Policy: default-src 'none'; … sandbox`, `X-Content-Type-Options: nosniff`) for a route of your own that returns an uploaded file's bytes from the site's origin. In a Next project a site-wide `headers()` rule with the same key overrides a header the route sets itself: add a `headers()` rule for the path after the site-wide one (as `buildUploadSecurityHeaders({ collections, adminIcon })` does for the upload routes and `/api/ipal/admin-icon`), and never answer with an SVG. |
|
||||
| `twoFactorSetupState(req)`, `twoFactorSetupDeadline(req)` | `@intecion/ipal-kit` | Where an account stands with TOTP setup, from `{ payload, user }`: `'set-up'`, `'open'` (may set it up now), `'closed'` (the setup window has passed: blocked until an admin reopens it), `'exempt'` (`requireSetup.exempt`, or `requireSetup: false`), `'not-applicable'` (no user, another collection, 2FA off); and the moment setup closes (`Date`, or `null` without a window). Types: `TwoFactorSetupState`, `RequireSetupOptions`. |
|
||||
| `requireSecondFactor(access?)` | `@intecion/ipal-kit` | Wraps an `Access` function: refused while the second factor is owed, otherwise the function itself (Payload's default "logged in" when none). iapl applies it to every collection and global in the config, and to those added by plugins listed after it (in `onInit` and at the start of the first request, so also after a dev hot reload); use it for access functions that are not part of the config. Per-entity opt-out: `custom.ipal.secondFactor: false \| { read: false }` or the package's `custom.totp.disableAccessWrapper`. Wrapping twice is harmless. |
|
||||
|
||||
@@ -188,7 +188,7 @@ export default buildConfig({
|
||||
seo: { collections: ['pages'] },
|
||||
forms: { redirectRelationships: ['pages'] },
|
||||
twoFactor: { issuer: '<Client name>', plugin: payloadTotp },
|
||||
whiteLabel: true,
|
||||
whiteLabel: { signIn: { allScreens: true } }, // client's logo / name on every sign-in screen (white-label.md)
|
||||
indexNow: true,
|
||||
// consentLog is on by default (1.17.0): consent-records + POST /api/ipal/consent; `consentLog: false` turns it off.
|
||||
// Postgres / SQLite: pnpm payload migrate:create consent-log, applied in the same deploy.
|
||||
@@ -207,7 +207,7 @@ are never added to a new site. Local `.env` with `PAYLOAD_SECRET` ≥ 32 charact
|
||||
One language: one entry in `locales`, no `[locale]` folder (i18n.md).
|
||||
|
||||
**Check.** `pnpm payload generate:importmap` (whiteLabel adds admin components) and `pnpm generate:types` without
|
||||
errors (the import map lists `@intecion/ipal-kit/admin#TotpRedirectProvider` and `#SafeTotpView`); `pnpm dev`, `/admin`: first-user screen → after saving, TOTP setup is enforced (`/admin/setup-totp?back=%2Fadmin`, QR, no reloading);
|
||||
errors (the import map lists `@intecion/ipal-kit/admin#TotpRedirectProvider`, `#SafeTotpView` and `#SignInLook`); `pnpm dev`, `/admin`: first-user screen → after saving, TOTP setup is enforced (`/admin/setup-totp?back=%2Fadmin`, QR, no reloading);
|
||||
the panel shows Site settings, Site integrations, Cookies, Form messages, the Forms group, Consent records.
|
||||
`curl -s -o /dev/null -w '%{http_code}' -X POST localhost:3000/api/ipal/consent -H 'content-type: application/json'
|
||||
-d '{"id":"0123456789abcdef","version":1,"state":{"necessary":true,"functional":false,"analytics":false,"marketing":false}}'` → `201`.
|
||||
@@ -294,6 +294,12 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
win; a function `(global) => global` takes over). Without `revalidatePath` global saves wait for the ISR window.
|
||||
- `whiteLabel: { credit: false, titleSuffix, settingsSlug, logoField, … }`; with `whiteLabel` the plugin overrides
|
||||
`graphics.Logo/Icon` — your own graphics only without it.
|
||||
- Sign-in screens (`whiteLabel.signIn`, on): a dark panel with the client's logo or the site's name beside the
|
||||
form; the logo and name are Site settings fields (no env var, no migration). `allScreens: true` (in the config
|
||||
above) adds the provider `SignInLook` to the import map and covers forgot / reset password, first user and
|
||||
logout. `accent: '#hex'`, `logoMadeFor: 'dark'` (a white logo), `languages: false`, `svgLogo: false`;
|
||||
`signIn: false` = Payload's screens; `brandAccess: 'admin'` = only admins change name, logo and icon.
|
||||
Check: `/admin/login` and `/admin/forgot` show the panel, also at a phone width; do not write login CSS by hand.
|
||||
- Panel link preview (`adminMeta`, on): noindex/nofollow, "— <site> | Panel" suffix, site name, description and
|
||||
preview image (`/api/ipal/admin-og`) from Site settings; `agency` names who supports the technology (default
|
||||
Intecion.com). Turn off: `adminMeta: false`, `agency: false`; your own `admin.meta` keys win. Check:
|
||||
|
||||
@@ -648,6 +648,22 @@ PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; re
|
||||
**Send test e-mail** names the transport you expect; a form submission arrives. **The service is live at
|
||||
`https://webservices.intecion.net/mail`; while the service runs with enrolment "pending" (from its launch until Intecion switches to open enrolment), every new site waits for approval — keep SMTP until it is approved, or `relay: false`.**
|
||||
|
||||
**→ 1.18.0, the sign-in look (CHANGELOG 1.18.0; white-label.md → "The sign-in screens") — nothing is required:**
|
||||
1. **Sites with `whiteLabel`:** after the update the login screen and the 2FA screens (code, setup) have the new
|
||||
look — a dark panel with the client's logo or the site's name beside the form. No edit, no
|
||||
`generate:importmap`, no migration: the look comes through `AdminLogo` and `SafeTotpView`, which the site's
|
||||
import map already has. **Check:** open `/admin/login` on a desktop and at a phone width, in both themes; sign
|
||||
in through 2FA. A logo that looks wrong on the white plate (a white logo): `signIn: { logoMadeFor: 'dark' }`.
|
||||
2. **Tell the owner the sign-in page looks different** and ask whether to keep it. No: `whiteLabel: { signIn: false }`
|
||||
— Payload's screens with the plain logo, as before (record it in AGENTS.md → Project decisions).
|
||||
3. **Recommended, one edit:** `whiteLabel: { signIn: { allScreens: true } }`, `pnpm payload generate:importmap`,
|
||||
commit `importMap.js` — forgot / reset password, create first user and logout get the same look. Forgetting
|
||||
the import map does not break the panel: at a production start the provider is left out and the log says so.
|
||||
4. **Project CSS for the login screen** (`custom.scss` rules on `.login`, `.template-minimal`, a hand-made
|
||||
`graphics.Logo`): look at the screens after the update; the look's own rules win over Payload's layer but not
|
||||
over the project's later ones. Restyle with the `--iapl-signin-*` variables instead.
|
||||
5. Sites **without** `whiteLabel`: nothing changes.
|
||||
|
||||
## 2. Inventory (no code changes)
|
||||
**What changed for projects** between your old and new plugin version is exactly the reference site's diff —
|
||||
`git diff v<old> v<new> -- reference/` in the IAPL repo (or the two `docs/agent/reference-site/INDEX.md` files):
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { expect, type Page, test } from '@playwright/test'
|
||||
|
||||
/**
|
||||
* The sign-in look (whiteLabel.signIn, white-label.md): the dark panel with the site's name or logo beside the
|
||||
* form, on every sign-in screen (this site sets `allScreens`), in the page's first HTML, on a phone above the
|
||||
* form, with working language links; and the 2FA code screen behind it, unchanged in what it does.
|
||||
* No 2FA code is entered here: the account's verify attempts are left for the other specs.
|
||||
* E2E_BASE_URL=http://localhost:3310 pnpm exec playwright test e2e/sign-in-look.spec.ts
|
||||
*/
|
||||
const { E2E_ADMIN_EMAIL: email, E2E_ADMIN_PASSWORD: password } = process.env
|
||||
|
||||
const PHONE = { height: 844, width: 390 }
|
||||
const panel = (page: Page) => page.locator('.iapl-signin')
|
||||
const box = async (page: Page, selector: string) => {
|
||||
const b = await page.locator(selector).first().boundingBox()
|
||||
if (!b) {throw new Error(`${selector} is not on the page`)}
|
||||
return b
|
||||
}
|
||||
/** Nothing is wider than the window: no sideways scroll. */
|
||||
const noSidewaysScroll = async (page: Page) => expect(await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth)).toBe(true)
|
||||
|
||||
test('sign-in look — login: the look comes with the form (no flash of the plain screen), one panel, the form beside it', async ({ page, request }) => {
|
||||
// the stylesheet and the panel are in the page's own response: no second request brings the look
|
||||
const html = await (await request.get('/admin/login')).text()
|
||||
expect(html).toContain('iapl-sign-in')
|
||||
expect(html).toContain('iapl-signin__label')
|
||||
|
||||
const errors: string[] = []
|
||||
page.on('console', (m) => m.type() === 'error' && errors.push(m.text()))
|
||||
// Payload draws its screens in the browser. Whenever the form's template is in the page, the panel and its
|
||||
// stylesheet must be there too — checked after every change of the page, before the browser paints it.
|
||||
await page.addInitScript(() => {
|
||||
const seen = { plain: 0, styled: 0 }
|
||||
;(window as unknown as { iaplLook: typeof seen }).iaplLook = seen
|
||||
new MutationObserver(() => {
|
||||
if (!document.querySelector('.template-minimal')) {return}
|
||||
const styled = document.querySelector('.iapl-signin') && document.querySelector('style[data-href="iapl-sign-in"]')
|
||||
seen[styled ? 'styled' : 'plain'] += 1
|
||||
}).observe(document, { childList: true, subtree: true })
|
||||
})
|
||||
await page.goto('/admin/login')
|
||||
await page.locator('#field-email').waitFor()
|
||||
const seen = await page.evaluate(() => (window as unknown as { iaplLook: { plain: number; styled: number } }).iaplLook)
|
||||
expect(seen.plain).toBe(0)
|
||||
expect(seen.styled).toBeGreaterThan(0)
|
||||
await expect(panel(page)).toHaveCount(1)
|
||||
await expect(panel(page)).toBeVisible()
|
||||
await expect(panel(page).locator('.iapl-signin__label')).toHaveText(/Administration panel|Panel administracyjny/)
|
||||
// the site's name (no logo in the seed) is a link to the site; nothing else on the panel leaves the admin
|
||||
await expect(panel(page).locator('.iapl-signin__brand')).toHaveText('Example Studio')
|
||||
await expect(panel(page).locator('.iapl-signin__brand')).toHaveAttribute('href', '/')
|
||||
const p = await box(page, '.iapl-signin')
|
||||
const form = await box(page, '#field-email')
|
||||
expect(p.x + p.width).toBeLessThanOrEqual(form.x)
|
||||
expect(p.height).toBeGreaterThan(600)
|
||||
await noSidewaysScroll(page)
|
||||
// the button carries the accent, the fields their labels
|
||||
await expect(page.locator('.form-submit button')).toHaveCSS('background-color', 'rgb(0, 112, 192)')
|
||||
await expect(page.getByLabel(/^(Email|E-mail)/)).toBeVisible()
|
||||
expect(errors).toEqual([])
|
||||
})
|
||||
|
||||
test('sign-in look — login on a phone: the panel is a band above the form, in both themes', async ({ baseURL, browser }) => {
|
||||
for (const theme of ['light', 'dark'] as const) {
|
||||
const context = await browser.newContext({ baseURL, viewport: PHONE })
|
||||
await context.addCookies([{ name: 'payload-theme', url: baseURL!, value: theme }])
|
||||
const page = await context.newPage()
|
||||
await page.goto('/admin/login')
|
||||
const p = await box(page, '.iapl-signin')
|
||||
const form = await box(page, '#field-email')
|
||||
expect(p.y).toBe(0)
|
||||
expect(Math.round(p.width)).toBe(PHONE.width)
|
||||
expect(p.y + p.height).toBeLessThanOrEqual(form.y)
|
||||
await noSidewaysScroll(page)
|
||||
await expect(page.locator('html')).toHaveAttribute('data-theme', theme)
|
||||
// the page behind the form follows the theme; the panel is dark in both
|
||||
const bg = await page.locator('.template-minimal').evaluate((el) => getComputedStyle(el).backgroundColor)
|
||||
expect(bg === 'rgb(255, 255, 255)').toBe(theme === 'light')
|
||||
await expect(panel(page)).toHaveCSS('background-color', 'rgb(6, 6, 6)')
|
||||
await context.close()
|
||||
}
|
||||
})
|
||||
|
||||
test('sign-in look — the other sign-in screens carry the same panel; the rest of the admin does not show it', async ({ page }) => {
|
||||
for (const path of ['/admin/forgot', '/admin/reset/not-a-real-token', '/admin/logout']) {
|
||||
await page.goto(path)
|
||||
await page.waitForLoadState('networkidle')
|
||||
await expect(panel(page), path).toHaveCount(1)
|
||||
await expect(panel(page), path).toBeVisible()
|
||||
await noSidewaysScroll(page)
|
||||
}
|
||||
await page.goto('/admin/forgot')
|
||||
const p = await box(page, '.iapl-signin')
|
||||
const form = await box(page, '#field-email')
|
||||
expect(p.x + p.width).toBeLessThanOrEqual(form.x)
|
||||
})
|
||||
|
||||
test('sign-in look — language links: one click changes the panel\'s language and comes back to the same screen', async ({ baseURL, browser, request }) => {
|
||||
const context = await browser.newContext({ baseURL, locale: 'en-US' })
|
||||
const page = await context.newPage()
|
||||
await page.goto('/admin/forgot')
|
||||
await expect(panel(page).locator('.iapl-signin__label')).toHaveText('Administration panel')
|
||||
await expect(panel(page).locator('[aria-current="true"]')).toHaveText('English')
|
||||
// a plain link: the endpoint sets the cookie and redirects, no script of the page takes part
|
||||
await expect(panel(page).getByRole('link', { name: 'Polski' })).toHaveAttribute('href', '/api/ipal/admin-language?lng=pl')
|
||||
await panel(page).getByRole('link', { name: 'Polski' }).click()
|
||||
await expect(page).toHaveURL(/\/admin\/forgot$/)
|
||||
await expect(panel(page).locator('.iapl-signin__label')).toHaveText('Panel administracyjny')
|
||||
await expect(panel(page).locator('[aria-current="true"]')).toHaveText('Polski')
|
||||
await expect(page.locator('html')).toHaveAttribute('lang', 'pl')
|
||||
await context.close()
|
||||
|
||||
// the endpoint writes a supported language only, and never sends the browser off the admin
|
||||
const unknown = await request.get('/api/ipal/admin-language?lng=xx', { maxRedirects: 0 })
|
||||
expect(unknown.status()).toBe(400)
|
||||
expect(unknown.headers()['set-cookie']).toBeUndefined()
|
||||
const away = await request.get('/api/ipal/admin-language?lng=pl', { headers: { referer: 'https://evil.example/phish' }, maxRedirects: 0 })
|
||||
expect(away.status()).toBe(303)
|
||||
expect(away.headers().location).toBe('/admin')
|
||||
expect(away.headers()['set-cookie']).toMatch(/^payload-lng=pl; Path=\/; Max-Age=31536000; SameSite=Lax/)
|
||||
})
|
||||
|
||||
test('sign-in look — the 2FA code screen: the panel beside it, the code boxes named, the brand without a media request', async ({ page }) => {
|
||||
test.skip(!email || !password, 'E2E_* test admin not configured')
|
||||
const media: string[] = []
|
||||
page.on('request', (r) => r.url().includes('/api/media/') && media.push(r.url()))
|
||||
await page.goto('/admin/login')
|
||||
await page.fill('#field-email', email!)
|
||||
await page.fill('#field-password', password!)
|
||||
await page.click('.form-submit button')
|
||||
await page.waitForURL(/verify-totp/)
|
||||
await expect(panel(page)).toHaveCount(1)
|
||||
await expect(panel(page)).toBeVisible()
|
||||
const p = await box(page, '.iapl-signin')
|
||||
const first = await box(page, '.template-minimal form input[type="text"]')
|
||||
expect(p.x + p.width).toBeLessThanOrEqual(first.x)
|
||||
// six boxes, each with a name a screen reader can say, the first one focused as before
|
||||
const boxes = page.getByRole('textbox')
|
||||
await expect(boxes).toHaveCount(6)
|
||||
await expect(boxes.first()).toHaveAttribute('aria-label', /^(Digit 1 of 6|Cyfra 1 z 6)$/)
|
||||
await expect(boxes.nth(5)).toHaveAttribute('aria-label', /^(Digit 6 of 6|Cyfra 6 z 6)$/)
|
||||
await expect(boxes.first()).toBeFocused()
|
||||
// a session that owes its code is refused `media`: the page asks for none
|
||||
expect(media).toEqual([])
|
||||
await noSidewaysScroll(page)
|
||||
})
|
||||
@@ -512,6 +512,8 @@ test('admin: sign in through 2FA, agency credit, panel link preview', async ({ p
|
||||
}
|
||||
await expect(page).toHaveTitle(/Dashboard|Pulpit/, { timeout: 20_000 })
|
||||
await expect(page.getByText(/Intecion/).first()).toBeVisible()
|
||||
// the sign-in panel belongs to the sign-in screens: inside the panel it is not shown
|
||||
await expect(page.locator('.iapl-signin')).toBeHidden()
|
||||
})
|
||||
|
||||
// 2FA covers what the plugin adds, over the API too (REST and GraphQL): a correct password without the code
|
||||
|
||||
@@ -44,6 +44,7 @@ import { TwoFactorAlert as TwoFactorAlert_7568fe47d582ff15ce85d2e1873c2c23 } fro
|
||||
import { CookieCrawlAlert as CookieCrawlAlert_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { IntegrationAlerts as IntegrationAlerts_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { TotpRedirectProvider as TotpRedirectProvider_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { SignInLook as SignInLook_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { SafeTotpView as SafeTotpView_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { CookieApprovalView as CookieApprovalView_7568fe47d582ff15ce85d2e1873c2c23 } from '@intecion/ipal-kit/admin'
|
||||
import { CollectionCards as CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1 } from '@payloadcms/next/rsc'
|
||||
@@ -99,6 +100,7 @@ export const importMap = {
|
||||
"@intecion/ipal-kit/admin#CookieCrawlAlert": CookieCrawlAlert_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#IntegrationAlerts": IntegrationAlerts_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#TotpRedirectProvider": TotpRedirectProvider_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#SignInLook": SignInLook_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#SafeTotpView": SafeTotpView_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@intecion/ipal-kit/admin#CookieApprovalView": CookieApprovalView_7568fe47d582ff15ce85d2e1873c2c23,
|
||||
"@payloadcms/next/rsc#CollectionCards": CollectionCards_f9c02e79a4aed9a3924487c0cd4cafb1,
|
||||
|
||||
@@ -100,7 +100,8 @@ export default buildConfig({
|
||||
//: twoFactor: false, // turned off by the owner — AGENTS.md → Project decisions, iapl-doctor.json
|
||||
// @starter:endif
|
||||
// @starter:if whiteLabel
|
||||
whiteLabel: true,
|
||||
// the sign-in look on every sign-in screen: one admin provider, in the import map (white-label.md)
|
||||
whiteLabel: { signIn: { allScreens: true } },
|
||||
// @starter:endif
|
||||
// @starter:if !adminMeta
|
||||
//: adminMeta: false, // turned off by the owner — AGENTS.md → Project decisions
|
||||
|
||||
Reference in New Issue
Block a user