core: fix lostpass send mail limit (#659)

This commit is contained in:
panda authored and GitHub committed 2023-09-07 06:07:56 +08:00
1 parent 84962bfc64
commit 7b80e4d2a5
1 file changed
+5
+5
View File
@@ -332,6 +332,11 @@ class UserLostPassHandler extends Handler {
if (!system.get('smtp.user')) throw new SystemError('Cannot send mail');
const udoc = await user.getByEmail('system', mail);
if (!udoc) throw new UserNotFoundError(mail);
await Promise.all([
this.limitRate('send_mail', 3600, 30, false),
this.limitRate(`user_lostpass_${mail}`, 60, 5, false),
oplog.log(this, 'user.lostpass', {}),
]);
const [tid] = await token.add(
token.TYPE_LOSTPASS,
system.get('session.unsaved_expire_seconds'),