pis #12

Merged
fred.boniface merged 95 commits from pis into main 2023-05-06 21:54:51 +01:00
1 changed files with 6 additions and 2 deletions
Showing only changes of commit ca690c7a7e - Show all commits

View File

@ -2,6 +2,7 @@ const log = require('../utils/log.utils');
const crypto = require('crypto')
const db = require('../services/dbAccess.services');
const fs = require('fs/promises')
const minify = require('html-minifier').minify;
// Checks users registration key against issued keys
async function isAuthed(uuid) { // Needs testing
@ -32,13 +33,16 @@ async function generateKey() { // Needs testing & moving to 'register.utils'
async function generateConfirmationEmail(eml, uuid) {
try {
let htmlTpl = fs.readFile('mail-templates/register.html', 'utf-8');
let htmlTpl = await fs.readFile('mail-templates/register.html', 'utf-8');
let minify = await minify(((htmlTpl).replace(/>>ACCESSCODE<</g, uuid)), {
removeComments: true
});
let txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8');
return msg = {
to: eml,
subject: "OwlBoard Registration",
text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid),
html: (await htmlTpl).replace(/>>ACCESSCODE<</g, uuid)
html: minify
}
} catch(err) {
log.out(`mailServices.generateConfirmationEmail: Error reading templates, $(err)`, "err");