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
@@ -0,0 +1,16 @@
|
||||
/** A locked staff account answers like a wrong password with 2FA off too (lockedAnswerSuite.ts). */
|
||||
import { describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { lockedAnswerSite, PASSWORD } from './lockedAnswerSuite.js'
|
||||
|
||||
vi.mock('server-only', () => ({}))
|
||||
|
||||
const { gqlLogin, lock, restLogin } = lockedAnswerSite({ twoFactor: false })
|
||||
|
||||
describe('accounts.lockedAnswer with twoFactor: false', () => {
|
||||
test('REST and GraphQL answer the locked owner like an invented address', async () => {
|
||||
await lock('users', '[email protected]')
|
||||
expect(await restLogin('users', '[email protected]', PASSWORD)).toEqual(await restLogin('users', '[email protected]', 'x-wrong-password-1'))
|
||||
expect(await gqlLogin('loginUser', '[email protected]', PASSWORD)).toEqual(await gqlLogin('loginUser', '[email protected]', 'x-wrong-password-1'))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user