From 3945548b602ae1ba91dc231869d27dab7f2f10fc Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:21:08 +0100 Subject: Fix recovery emails (#85) * Fix recovery emails * Update sender to random smtp for tests --- app/Models/User.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/Models/User.ts') diff --git a/app/Models/User.ts b/app/Models/User.ts index 0ed4627..0b8e688 100644 --- a/app/Models/User.ts +++ b/app/Models/User.ts @@ -14,6 +14,9 @@ import randtoken from 'rand-token'; import Token from './Token'; import Workspace from './Workspace'; import Service from './Service'; +import Mail from '@ioc:Adonis/Addons/Mail'; +import { url } from 'Config/app'; +import { mailFrom } from 'Config/dashboard'; export default class User extends BaseModel { @column({ isPrimary: true }) @@ -66,6 +69,18 @@ export default class User extends BaseModel { public async forgotPassword(): Promise { const token = await this.generateToken(this, 'forgot_password'); + await Mail.send(message => { + message + .from(mailFrom) + .to(this.email) + .subject('[Ferdium] Password Recovery') + .htmlView('emails/reset_password', { + username: this.username, + appUrl: url, + token: token, + }); + }); + await Event.emit('forgot:password', { user: this, token, -- cgit v1.2.3-54-g00ecf