aboutsummaryrefslogtreecommitdiffstats
path: root/start/events.js
blob: 0b7e28ad7de45c191add21e8166b116289da7d14 (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
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) {}
});