core: fix lostpass send mail limit (#659)

pull/654/head
panda 1 year ago committed by GitHub
parent 84962bfc64
commit 7b80e4d2a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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'),

Loading…
Cancel
Save