core: limits: allow by-user

This commit is contained in:
undefined committed 2022-11-19 10:27:57 +08:00
1 parent f65aba6d27
commit 273a0563b3
5 files changed
+10 -9

No files matched your search

+3 -3
View File
@@ -121,8 +121,8 @@ class UserLoginHandler extends Handler {
if (!udoc) udoc = await user.getByUname(domainId, uname);
if (!udoc) throw new UserNotFoundError(uname);
await Promise.all([
this.limitRate('user_login', 60, 30),
this.limitRate(`user_login_${uname}`, 60, 5),
this.limitRate('user_login', 60, 30, false),
this.limitRate(`user_login_${uname}`, 60, 5, false),
oplog.log(this, 'user.login', { redirect }),
]);
if (udoc._tfa && !verifyToken(udoc._tfa, tfa)) throw new InvalidTokenError('2FA token invalid.');
@@ -199,7 +199,7 @@ export class UserRegisterHandler extends Handler {
const mailDomain = mail.split('@')[1];
if (await BlackListModel.get(`mail::${mailDomain}`)) throw new BlacklistedError(mailDomain);
await Promise.all([
this.limitRate('send_mail', 3600, 30),
this.limitRate('send_mail', 3600, 30, false),
oplog.log(this, 'user.register', {}),
]);
const t = await token.add(