blob: faedc299e2891db0f378d47fca28a337f632a32d (
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 { Config } from '@adonisjs/core/config'
import emitter from '@adonisjs/core/services/emitter'
import mail from '@adonisjs/mail/services/main'
/*
|--------------------------------------------------------------------------
| 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}`)
}
})
|