From d3fad7c22807738ebb85aef3ebf2d44b51f5999c Mon Sep 17 00:00:00 2001 From: Ivan Polchenko <2119240+i5okie@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:39:14 -0800 Subject: [PATCH] ensure SECURE is a bool Signed-off-by: Ivan Polchenko <2119240+i5okie@users.noreply.github.com> --- services/tenant-ui/src/components/email.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/services/tenant-ui/src/components/email.ts b/services/tenant-ui/src/components/email.ts index 4b30c266e..19b041bb3 100644 --- a/services/tenant-ui/src/components/email.ts +++ b/services/tenant-ui/src/components/email.ts @@ -20,6 +20,15 @@ const INNKEEPER: string = config.get("server.smtp.innkeeperInbox"); const eta = new Eta(); +/** + * @function stringOrBooleanTruthy + * Returns true if the value is a string "true" or a boolean true, returns false otherwise + * @returns {boolean} + */ +export function stringOrBooleanTruthy(value: string | boolean) { + return value === 'true' || value === true; +} + /** * @function sendConfirmationEmail * Send the preconfigured emails when a reservation is created @@ -30,7 +39,7 @@ export const sendConfirmationEmail = async (req: Request) => { const transporter = nodemailer.createTransport({ host: SERVER, port: PORT, - secure: SECURE, + secure: stringOrBooleanTruthy(SECURE), auth: { user: USER, pass: PASSWORD, @@ -76,7 +85,7 @@ export const sendStatusEmail = async (req: Request) => { const transporter = nodemailer.createTransport({ host: SERVER, port: PORT, - secure: SECURE, + secure: stringOrBooleanTruthy(SECURE), auth: { user: USER, pass: PASSWORD,