M1 (5): the lowest role stays out of the admin panel (accounts.panelRole)

The panel opens for editor and above by default: Payload's access.admin on the
collection that carries the roles. An account that holds only `user` sees
"Unauthorized" there; the API is not touched. The rule looks at the role, not
at the second factor, so the 2FA screens stay reachable. accounts.panelRole:
'user' | false (everyone, as before) | 'admin'; accounts: false turns the account
rules off; the project's own access.admin wins. At start the log says how many
accounts the rule keeps out, and is an error when it keeps everyone out.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 00:39:12 +01:00
co-authored by Claude Fable 5.2
parent 463fd5d664
commit cd60b73685
7 changed files with 259 additions and 2 deletions
+6 -1
View File
@@ -13,7 +13,7 @@ export type TotpPluginFactory = (options: {
totp: { issuer: string }
}) => Plugin
import type { GlobalOverrides } from './globals/overrides.js'
import type { AccessOption } from './modules/access/types.js'
import type { AccessOption, AccountsOptions } from './modules/access/types.js'
import type { AdminMetaOptions, AgencyOption } from './modules/branding/adminMeta.js'
import type { ConsentLogOptions } from './modules/consent/consentLog.js'
import type { CookieScannerOptions } from './modules/consent/scanner/types.js'
@@ -34,6 +34,11 @@ import type { StatsOptions } from './modules/stats/collection.js'
* Passed by the client project in payload.config.ts.
*/
export type IpalOptions = {
/**
* Rules for the accounts of the staff collection: who may open the panel
* (`panelRole`). `false` = none of them. docs/access.md "Account rules".
*/
accounts?: AccountsOptions | false
/**
* Role-based access control. Injects a fixed `roles` field
* (admin > editor > user) into the client's auth collection.