pis #12

Merged
fred.boniface merged 95 commits from pis into main 2023-05-06 21:54:51 +01:00
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 crypto = require('crypto')
const db = require('../services/dbAccess.services'); const db = require('../services/dbAccess.services');
const fs = require('fs/promises') const fs = require('fs/promises')
const minify = require('html-minifier').minify;
// Checks users registration key against issued keys // Checks users registration key against issued keys
async function isAuthed(uuid) { // Needs testing async function isAuthed(uuid) { // Needs testing
@ -32,13 +33,16 @@ async function generateKey() { // Needs testing & moving to 'register.utils'
async function generateConfirmationEmail(eml, uuid) { async function generateConfirmationEmail(eml, uuid) {
try { 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'); let txtTpl = fs.readFile('mail-templates/register.txt', 'utf-8');
return msg = { return msg = {
to: eml, to: eml,
subject: "OwlBoard Registration", subject: "OwlBoard Registration",
text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid), text: (await txtTpl).replace(/>>ACCESSCODE<</g, uuid),
html: (await htmlTpl).replace(/>>ACCESSCODE<</g, uuid) html: minify
} }
} catch(err) { } catch(err) {
log.out(`mailServices.generateConfirmationEmail: Error reading templates, $(err)`, "err"); log.out(`mailServices.generateConfirmationEmail: Error reading templates, $(err)`, "err");