Added email for when email address is confirmed

This commit is contained in:
Jonathan Barrow
2022-10-01 01:26:00 -04:00
parent 48aabe0bfc
commit fd455fae91
3 changed files with 17 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
const router = require('express').Router();
const moment = require('moment');
const { PNID } = require('../../../../models/pnid');
const util = require('../../../../util');
router.get('/verify', async (request, response) => {
const { token } = request.query;
@@ -33,6 +34,8 @@ router.get('/verify', async (request, response) => {
await pnid.save();
await util.sendEmailConfirmedEmail(pnid);
response.status(200).send('Email validated. You may close this window');
});

View File

@@ -84,6 +84,8 @@ router.put('/email_confirmation/:pid/:code', async (request, response) => {
await pnid.save();
await util.sendEmailConfirmedEmail(pnid);
response.status(200).send('');
});

View File

@@ -232,8 +232,16 @@ function nascError(errorCode) {
async function sendConfirmationEmail(pnid) {
await mailer.sendMail({
to: pnid.get('email.address'),
subject: '[Pretendo Network] Please confirm your e-mail address',
html: `Hello,<br><br>Your Pretendo Network ID activation is almost complete. Please click the link below to confirm your e-mail address and complete the activation process.<br><br>https://api.pretendo.cc/v1/email/verify?token=${pnid.get('identification.email_token')}<br><br>If you are unable to connect to the above URL, please enter the following confirmation code on the device to which your Prentendo Network ID is linked.<br><br>&lt;&lt;Confirmation code: ${pnid.get('identification.email_code')}&gt;&gt;`
subject: '[Pretendo Network] Please confirm your email address',
html: `Hello,<br><br>Your Pretendo Network ID activation is almost complete.<br><br>Please click the link below to confirm your e-mail address and complete the activation process.<br><br>https://api.pretendo.cc/v1/email/verify?token=${pnid.get('identification.email_token')}<br><br>If you are unable to connect to the above URL, please enter the following confirmation code on the device to which your Prentendo Network ID is linked.<br><br>&lt;&lt;Confirmation code: ${pnid.get('identification.email_code')}&gt;&gt;`
});
}
async function sendEmailConfirmedEmail(pnid) {
await mailer.sendMail({
to: pnid.get('email.address'),
subject: '[Pretendo Network] Email address confirmed',
html: 'Your email address has been confirmed!'
});
}
@@ -247,5 +255,6 @@ module.exports = {
fullUrl,
uploadCDNAsset,
nascError,
sendConfirmationEmail
sendConfirmationEmail,
sendEmailConfirmedEmail
};