diff options
author | vantezzen <hello@vantezzen.io> | 2020-04-02 17:09:11 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2020-04-02 17:09:11 +0200 |
commit | 6ed9da44690d5f68a5bb4e398c0a4ad4083ed6fa (patch) | |
tree | 77778897d7411d7c273d1b1bdf7caf7ba75f85e2 /start/events.js | |
parent | Upgrade dependencies (diff) | |
download | ferdium-server-6ed9da44690d5f68a5bb4e398c0a4ad4083ed6fa.tar.gz ferdium-server-6ed9da44690d5f68a5bb4e398c0a4ad4083ed6fa.tar.zst ferdium-server-6ed9da44690d5f68a5bb4e398c0a4ad4083ed6fa.zip |
#16 Implement Password reset
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 | ||