fix(xo-server/authenticateUser): use clearLogOnSuccess
This fixes success logs not deleted due to race conditions.
This commit is contained in:
parent
e3dd59d684
commit
3f8436b58b
@ -138,14 +138,20 @@ export default class {
|
|||||||
|
|
||||||
async authenticateUser(credentials, userData) {
|
async authenticateUser(credentials, userData) {
|
||||||
const { tasks } = this._app
|
const { tasks } = this._app
|
||||||
const task = await tasks.create({
|
const task = await tasks.create(
|
||||||
type: 'xo:authentication:authenticateUser',
|
{
|
||||||
name: 'XO user authentication',
|
type: 'xo:authentication:authenticateUser',
|
||||||
credentials: replace(credentials),
|
name: 'XO user authentication',
|
||||||
userData,
|
credentials: replace(credentials),
|
||||||
})
|
userData,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// only keep trace of failed attempts
|
||||||
|
clearLogOnSuccess: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const result = await task.run(async () => {
|
return task.run(async () => {
|
||||||
// don't even attempt to authenticate with empty password
|
// don't even attempt to authenticate with empty password
|
||||||
const { password } = credentials
|
const { password } = credentials
|
||||||
if (password === '') {
|
if (password === '') {
|
||||||
@ -177,11 +183,6 @@ export default class {
|
|||||||
delete failures[username]
|
delete failures[username]
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|
||||||
// only keep trace of failed attempts
|
|
||||||
await tasks.deleteLog(task.id)
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------
|
// -----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user