feat: Rate limiter on requests and login attempts.

This commit is contained in:
a.bouhuolia
2020-12-15 20:25:23 +02:00
parent 27483495cb
commit 6dd1229412
11 changed files with 170 additions and 4 deletions

View File

@@ -7,8 +7,14 @@ import events from 'subscribers/events';
export class AuthenticationSubscriber {
@On(events.auth.login)
public onLogin(payload) {
const { emailOrPhone, password } = payload;
public async onLogin(payload) {
const { emailOrPhone, password, user } = payload;
const loginThrottler = Container.get('rateLimiter.login');
// Reset the login throttle by the given email and phone number.
await loginThrottler.reset(user.email);
await loginThrottler.reset(user.phoneNumber);
}
@On(events.auth.register)