blob: b3667db827f332dee261400029ef803b2f7b7340 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import emitter from '@adonisjs/core/services/emitter';
import mail from '@adonisjs/mail/services/main';
import config from '@adonisjs/core/services/config';
/*
|--------------------------------------------------------------------------
| Preloaded File
|--------------------------------------------------------------------------
|
| Any code written inside this file will be executed during the application
| boot.
|
*/
emitter.on('forgot::password', async ({ user, token }) => {
try {
// eslint-disable-next-line no-console
console.log('Sending message');
await mail.send(message => {
message
.subject('[Ferdium] Forgot Password')
.to(user.email)
.from(config.get('dasshboard.mailFrom'))
.textView('emails.forgot-password', {
appUrl: config.get('app.url'),
username: user.username,
token,
});
});
} catch (error) {
// eslint-disable-next-line no-console
console.log(`Couldn't send mail: ${error}`);
}
});
|