A locked staff account answers its login like a wrong password (accounts.lockedAnswer)

Payload checks the lock before the password, so after five wrong passwords
a staff address answered "This user is locked…" to any password while an
address with no account always answered "The email or password provided is
incorrect.": anybody could find out which addresses have a staff account
(IAWL idea 6, owner's Q1). A config-level afterError hook now answers
LockedAuth on a staff collection's login exactly like AuthenticationError:
REST status and body, GraphQL message and extensions.name. The lock is
unchanged; visitor collections keep Payload's answer.
accounts: { lockedAnswer: 'payload' } keeps Payload's message; any other
value stops the start. Building blocks lockedLooksWrong, withLockedAnswer,
graphqlLoginName.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 10:39:40 +01:00
co-authored by Claude Opus 5.5
parent fc70a34f3e
commit 15b5c6258d
14 changed files with 262 additions and 2 deletions
+3
View File
@@ -13,6 +13,7 @@ import { applyGlobalOverrides } from './globals/overrides.js'
import { buildSiteIntegrations } from './globals/SiteIntegrations/index.js'
import { buildSiteSettings } from './globals/SiteSettings/index.js'
import { adminOnly, adminOrSelfIn, injectRoles, registerStaffCollections, staffCollectionSlugs } from './modules/access/index.js'
import { withLockedAnswer } from './modules/access/lockedAnswer.js'
import { applyPanelRole, countBelowPanelRole, resolvePanelRole } from './modules/access/panelRole.js'
import { applyPasswordRule, buildPasswordRuleHook, resolvePasswordRule } from './modules/access/passwordRule.js'
import { adoptLateAuthCollections, applyFirstUserRoute, applyStaffAccountAccess, markSeenAuthCollections, markStaffRules, staffCollectionsNobodyManages, unknownStaffCollections } from './modules/access/selfRegistration.js'
@@ -258,6 +259,8 @@ export const iapl = (options: IaplOptions): Plugin => {
const panelSlug = config.admin?.user ?? (config.collections ?? []).find((c) => c.auth)?.slug
const staffSlugs = [...new Set([panelSlug, options.access?.authCollection, ...(options.access?.staffCollections ?? [])].filter((s): s is string => Boolean(s)))]
config = applyStaffAccountAccess(config, staffSlugs, { ...accountAccess, pluginRoles: options.access?.authCollection ? [options.access.authCollection] : [] })
// A locked staff account answers like a wrong password (accounts.lockedAnswer).
if (accounts.lockedAnswer !== 'payload') {config = withLockedAnswer(config)}
}
if (options.twoFactor !== false) {
const tf = options.twoFactor