fix(auth): ttl for lock counter on login lockout

This commit is contained in:
Karol Sójko
2022-09-27 15:20:42 +02:00
parent d2fc1e057d
commit 54da5def4b
2 changed files with 2 additions and 3 deletions
@@ -15,7 +15,6 @@ describe('LockRepository', () => {
redisClient.expire = jest.fn()
redisClient.del = jest.fn()
redisClient.get = jest.fn()
redisClient.set = jest.fn()
redisClient.setex = jest.fn()
})
@@ -88,6 +87,6 @@ describe('LockRepository', () => {
it('should update a lock counter', async () => {
await createRepository().updateLockCounter('123', 3)
expect(redisClient.set).toHaveBeenCalledWith('lock:123', 3)
expect(redisClient.setex).toHaveBeenCalledWith('lock:123', 120, 3)
})
})
@@ -30,7 +30,7 @@ export class LockRepository implements LockRepositoryInterface {
}
async updateLockCounter(userIdentifier: string, counter: number): Promise<void> {
await this.redisClient.set(`${this.PREFIX}:${userIdentifier}`, counter)
await this.redisClient.setex(`${this.PREFIX}:${userIdentifier}`, this.failedLoginLockout, counter)
}
async getLockCounter(userIdentifier: string): Promise<number> {