Skip to content

Commit

Permalink
ensure SECURE is a bool
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Polchenko <[email protected]>
  • Loading branch information
i5okie committed Feb 5, 2024
1 parent 32b9672 commit d3fad7c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions services/tenant-ui/src/components/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d3fad7c

Please sign in to comment.