diff options
Diffstat (limited to 'start/events.js')
-rw-r--r-- | start/events.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/start/events.js b/start/events.js new file mode 100644 index 0000000..0b7e28a --- /dev/null +++ b/start/events.js | |||
@@ -0,0 +1,23 @@ | |||
1 | const Event = use('Event'); | ||
2 | const Mail = use('Mail'); | ||
3 | const Env = use('Env'); | ||
4 | |||
5 | Event.on('forgot::password', async ({ user, token }) => { | ||
6 | const body = ` | ||
7 | Hello ${user.username}, | ||
8 | we just recieved a request to reset your password of your Ferdi account. | ||
9 | Use the link below to reset your password. If you havn't requested this, please ignore this message. | ||
10 | |||
11 | ${Env.get('APP_URL')}/user/reset?token=${encodeURIComponent(token)} | ||
12 | |||
13 | This message was sent automatically. Please do not reply. | ||
14 | `; | ||
15 | console.log('Sending message', body); | ||
16 | try { | ||
17 | await Mail.raw(body, (message) => { | ||
18 | message.subject('[Ferdi] Reset your password') | ||
19 | message.from('noreply@getferdi.com') | ||
20 | message.to(user.email) | ||
21 | }); | ||
22 | } catch(e) {} | ||
23 | }); \ No newline at end of file | ||