aboutsummaryrefslogtreecommitdiffstats
path: root/start/events.ts
diff options
context:
space:
mode:
Diffstat (limited to 'start/events.ts')
-rw-r--r--start/events.ts33
1 files changed, 33 insertions, 0 deletions
diff --git a/start/events.ts b/start/events.ts
new file mode 100644
index 0000000..11e63e5
--- /dev/null
+++ b/start/events.ts
@@ -0,0 +1,33 @@
1import Config from '@ioc:Adonis/Core/Config';
2import Event from '@ioc:Adonis/Core/Event';
3import Mail from '@ioc:Adonis/Addons/Mail';
4
5/*
6|--------------------------------------------------------------------------
7| Preloaded File
8|--------------------------------------------------------------------------
9|
10| Any code written inside this file will be executed during the application
11| boot.
12|
13*/
14Event.on('forgot::password', async ({ user, token }) => {
15 try {
16 // eslint-disable-next-line no-console
17 console.log('Sending message');
18 await Mail.send(message => {
19 message
20 .subject('[Ferdium] Forgot Password')
21 .to(user.email)
22 .from(Config.get('dasshboard.mailFrom'))
23 .textView('emails.forgot-password', {
24 appUrl: Config.get('app.url'),
25 username: user.username,
26 token,
27 });
28 });
29 } catch (error) {
30 // eslint-disable-next-line no-console
31 console.log(`Couldn't send mail: ${error}`);
32 }
33});