(domainId: string, mail: string)
| 347 | |
| 348 | @param('mail', Types.Email) |
| 349 | async post(domainId: string, mail: string) { |
| 350 | if (!system.get('smtp.user')) throw new SystemError('Cannot send mail'); |
| 351 | const udoc = await user.getByEmail('system', mail); |
| 352 | if (!udoc) throw new UserNotFoundError(mail); |
| 353 | await Promise.all([ |
| 354 | this.limitRate('send_mail', 3600, 30), |
| 355 | this.limitRate('send_mail', 60, 1, mail), |
| 356 | oplog.log(this, 'user.lostpass', {}), |
| 357 | ]); |
| 358 | const [tid] = await token.add( |
| 359 | token.TYPE_LOSTPASS, |
| 360 | system.get('session.unsaved_expire_seconds'), |
| 361 | { uid: udoc._id }, |
| 362 | ); |
| 363 | const prefix = this.domain.host |
| 364 | ? `${this.domain.host instanceof Array ? this.domain.host[0] : this.domain.host}` |
| 365 | : system.get('server.url'); |
| 366 | const m = await this.renderHTML('user_lostpass_mail.html', { |
| 367 | url: `/lostpass/${tid}`, |
| 368 | url_prefix: prefix.endsWith('/') ? prefix.slice(0, -1) : prefix, |
| 369 | uname: udoc.uname, |
| 370 | }); |
| 371 | await sendMail(mail, 'Lost Password', 'user_lostpass_mail', m.toString()); |
| 372 | this.response.template = 'user_lostpass_mail_sent.html'; |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | class UserLostPassWithCodeHandler extends Handler { |
nothing calls this directly
no test coverage detected