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:
co-authored by
Claude Opus 5.5
parent
fc70a34f3e
commit
15b5c6258d
+21
-1
@@ -250,6 +250,7 @@ iapl({
|
||||
// accounts: { firstUserRoute: 'all' }, // Payload's first-user route for every empty auth collection
|
||||
// accounts: { firstUserRoute: ['users', 'partners'] },
|
||||
// accounts: { password: { minLength: 16 } }, // or password: false
|
||||
// accounts: { lockedAnswer: 'payload' }, // a locked staff account is told it is locked (Payload's answer)
|
||||
// accounts: false, // none of the rules
|
||||
})
|
||||
```
|
||||
@@ -477,10 +478,29 @@ characters."; texts `passwordTooShort`, `passwordIsEmail` in `i18n.translations.
|
||||
`DEFAULT_PASSWORD_MIN_LENGTH`.
|
||||
- **Check:** create an account with an 11-character password → "The password must have at least 12 characters.".
|
||||
|
||||
### A locked staff account answers like a wrong password (`accounts.lockedAnswer`, 1.17.2)
|
||||
|
||||
Payload locks an account after `maxLoginAttempts` wrong passwords (5 by default) for `lockTime` (10 minutes), and
|
||||
it checks the lock **before** the password: the locked account then gets `401 "This user is locked due to having too
|
||||
many failed login attempts."` for any password, while an address with no account always gets `401 "The email or
|
||||
password provided is incorrect."`. Five wrong guesses told anybody, without a password, whether an address has a
|
||||
staff account. Now a staff collection's login answers a locked account exactly like a wrong password — the same
|
||||
status, body and GraphQL `extensions.name` (`AuthenticationError`) — over REST, GraphQL and the panel's sign-in
|
||||
form. The lock itself is unchanged: the owner's correct password is still refused until it ends, and the owner is
|
||||
then told "wrong e-mail or password" (an administrator sees `lockUntil` on the account and can unlock it). Visitor
|
||||
collections (not staff) keep Payload's answer.
|
||||
|
||||
- **Turn off:** `accounts: { lockedAnswer: 'payload' }` (Payload's message), or `accounts: false`. Any other value
|
||||
stops the start.
|
||||
- **Building blocks:** `lockedLooksWrong` (the config-level `afterError` hook), `withLockedAnswer(config)`,
|
||||
`graphqlLoginName(collection)` (`login<SingularName>`, as GraphQL names the mutation).
|
||||
- **Check:** five wrong passwords for an admin's address, then `POST /api/users/login` with the right one → the same
|
||||
`401` body as for `nobody@example.com`; GraphQL `loginUser` → `extensions.name: "AuthenticationError"`.
|
||||
|
||||
## Turn off, override, extend
|
||||
|
||||
- **Account rules:** `accounts: false`, or one by one — `panelRole`, `adminOnlyCreate`, `adminOnlyWrite`,
|
||||
`staffOnlyRead`, `firstUserRoute`, `password` (above).
|
||||
`staffOnlyRead`, `firstUserRoute`, `password`, `lockedAnswer` (above).
|
||||
- **Turn off:** leave out `access` — no `roles` field, the auth collection keeps Payload's rules
|
||||
(or yours). `access.firstUserAdmin: false` stops giving admin to the first account.
|
||||
- **Override:** `access.staffCollections` (who is staff), `access.authAccess` (injected collection), your own auth collection (wins whole),
|
||||
|
||||
Reference in New Issue
Block a user