M1 review round 3: late staff collections without guessing Payload's default; rules survive a dev reload
R3-1 nothing is decided by a function's name any more (a production build renames it): on a collection that
arrives after ipalKit the plugin's rule is put in FRONT of the rule that is there and both must allow
(bothAllow). unlock follows the same table. The log says exactly what was put.
R3-2 the adoption walks the live config (payload.config), which Payload swaps first on a dev reload.
R3-3 readVersions gets the read rule on staff collections.
R3-5 a secret that is not text is refused.
Also: the async check of requireSetup.exempt compares the constructor, not its name.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
3e44863c98
commit
6e0ad26b2c
@@ -73,6 +73,9 @@ export function resolveRequireSetup(option: false | RequireSetupOptions | undefi
|
||||
/** What was already said about a wrong `exempt` answer: each kind is logged once per process. */
|
||||
const exemptComplaints = new Set<string>()
|
||||
|
||||
/** The constructor of async functions (there is no global for it). */
|
||||
const ASYNC_FUNCTION: unknown = (async () => {}).constructor
|
||||
|
||||
/**
|
||||
* The project's `exempt`, made safe to call from an access check: only an answer of exactly
|
||||
* `true` exempts. An async function is refused at start (its Promise would be truthy for every
|
||||
@@ -83,7 +86,8 @@ export function strictExempt(exempt: unknown): NonNullable<RequireSetupOptions['
|
||||
if (typeof exempt !== 'function') {
|
||||
throw new Error('[ipal] twoFactor.requireSetup.exempt must be a function: ({ user }) => boolean.')
|
||||
}
|
||||
if (exempt.constructor?.name === 'AsyncFunction') {
|
||||
// by the constructor itself, not by its name
|
||||
if (exempt.constructor === ASYNC_FUNCTION) {
|
||||
throw new Error(
|
||||
'[ipal] twoFactor.requireSetup.exempt must not be async: it is called in access checks, which cannot wait, and a Promise ' +
|
||||
'would count as "exempt" for every account. Return true or false at once (decide from the fields on `user`).',
|
||||
|
||||
Reference in New Issue
Block a user