From 6ed9da44690d5f68a5bb4e398c0a4ad4083ed6fa Mon Sep 17 00:00:00 2001 From: vantezzen Date: Thu, 2 Apr 2020 17:09:11 +0200 Subject: #16 Implement Password reset --- start/events.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 start/events.js (limited to 'start/events.js') 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 @@ +const Event = use('Event'); +const Mail = use('Mail'); +const Env = use('Env'); + +Event.on('forgot::password', async ({ user, token }) => { + const body = ` +Hello ${user.username}, +we just recieved a request to reset your password of your Ferdi account. +Use the link below to reset your password. If you havn't requested this, please ignore this message. + +${Env.get('APP_URL')}/user/reset?token=${encodeURIComponent(token)} + +This message was sent automatically. Please do not reply. +`; +console.log('Sending message', body); + try { + await Mail.raw(body, (message) => { + message.subject('[Ferdi] Reset your password') + message.from('noreply@getferdi.com') + message.to(user.email) + }); + } catch(e) {} +}); \ No newline at end of file -- cgit v1.2.3-54-g00ecf