From a1d2325156933a7a7fcda3fa125c8ecdfb03df02 Mon Sep 17 00:00:00 2001 From: Benjamin Toby Date: Tue, 10 Dec 2024 14:09:21 +0100 Subject: [PATCH] Bugfix --- .../api/users/api-send-email-code.js | 2 +- package.json | 2 +- users/send-email-code.d.ts | 22 ++++------ users/send-email-code.js | 43 +++---------------- 4 files changed, 18 insertions(+), 51 deletions(-) diff --git a/package-shared/functions/api/users/api-send-email-code.js b/package-shared/functions/api/users/api-send-email-code.js index 5dc6c33..8f58c50 100644 --- a/package-shared/functions/api/users/api-send-email-code.js +++ b/package-shared/functions/api/users/api-send-email-code.js @@ -79,7 +79,7 @@ module.exports = async function apiSendEmailCode({ let transporter = nodemailer.createTransport({ host: mail_domain || process.env.DSQL_MAIL_HOST, - port: mail_port || 465, + port: mail_port || process.env.DSQL_MAIL_PORT || 465, secure: true, auth: { user: mail_username || process.env.DSQL_MAIL_EMAIL, diff --git a/package.json b/package.json index e4d4e72..e8f858c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/datasquirel", - "version": "2.8.1", + "version": "2.8.2", "description": "Cloud-based SQL data management tool", "main": "index.js", "bin": { diff --git a/users/send-email-code.d.ts b/users/send-email-code.d.ts index fee2e78..cbbf816 100644 --- a/users/send-email-code.d.ts +++ b/users/send-email-code.d.ts @@ -11,13 +11,11 @@ export = sendEmailCode; * @async * * @param {object} params - Single Param object containing params - * @param {String} params.key - FULL ACCESS API Key - * @param {String} params.database - Target Database + * @param {String} [params.key] - FULL ACCESS API Key + * @param {String} [params.database] - Target Database * @param {string} params.email Login Email/Username and Password - * @param {http.ServerResponse} params.response - Http response object - * @param {String} params.encryptionKey - Encryption Key - * @param {String} params.encryptionSalt - Encryption Salt - * @param {string} [params.temp_code_field] - Database table field name for temporary code + * @param {http.ServerResponse} [params.response] - Http response object + * @param {string} [params.temp_code_field_name] - Database table field name for temporary code * @param {string} [params.mail_domain] * @param {string} [params.mail_username] * @param {string} [params.mail_password] @@ -28,14 +26,12 @@ export = sendEmailCode; * * @returns { Promise} */ -declare function sendEmailCode({ key, email, database, encryptionKey, encryptionSalt, temp_code_field, mail_domain, mail_password, mail_username, mail_port, sender, user_id, useLocal, }: { - key: string; - database: string; +declare function sendEmailCode({ key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, useLocal, }: { + key?: string; + database?: string; email: string; - response: http.ServerResponse; - encryptionKey: string; - encryptionSalt: string; - temp_code_field?: string; + response?: http.ServerResponse; + temp_code_field_name?: string; mail_domain?: string; mail_username?: string; mail_password?: string; diff --git a/users/send-email-code.js b/users/send-email-code.js index 0dfbd98..336623f 100644 --- a/users/send-email-code.js +++ b/users/send-email-code.js @@ -25,13 +25,11 @@ const apiSendEmailCode = require("../package-shared/functions/api/users/api-send * @async * * @param {object} params - Single Param object containing params - * @param {String} params.key - FULL ACCESS API Key - * @param {String} params.database - Target Database + * @param {String} [params.key] - FULL ACCESS API Key + * @param {String} [params.database] - Target Database * @param {string} params.email Login Email/Username and Password - * @param {http.ServerResponse} params.response - Http response object - * @param {String} params.encryptionKey - Encryption Key - * @param {String} params.encryptionSalt - Encryption Salt - * @param {string} [params.temp_code_field] - Database table field name for temporary code + * @param {http.ServerResponse} [params.response] - Http response object + * @param {string} [params.temp_code_field_name] - Database table field name for temporary code * @param {string} [params.mail_domain] * @param {string} [params.mail_username] * @param {string} [params.mail_password] @@ -46,9 +44,7 @@ async function sendEmailCode({ key, email, database, - encryptionKey, - encryptionSalt, - temp_code_field, + temp_code_field_name, mail_domain, mail_password, mail_username, @@ -61,8 +57,8 @@ async function sendEmailCode({ const { host, port, scheme } = grabedHostNames; const defaultTempLoginFieldName = "temp_login_code"; - const emailLoginTempCodeFieldName = temp_code_field - ? temp_code_field + const emailLoginTempCodeFieldName = temp_code_field_name + ? temp_code_field_name : defaultTempLoginFieldName; const emailHtml = fs.readFileSync( @@ -70,31 +66,6 @@ async function sendEmailCode({ "utf-8" ); - /** - * Check Encryption Keys - * - * @description Check Encryption Keys - */ - if (!encryptionKey?.match(/./)) { - console.log("DSQL Error => No Encryption Key Found!"); - return false; - } - - if (!encryptionSalt?.match(/./)) { - console.log("DSQL Error => No Encryption Salt Found!"); - return false; - } - - if (encryptionKey.length < 24) { - console.log("DSQL Error => Encryption key less than 24 characters!"); - return false; - } - - if (encryptionSalt.length < 8) { - console.log("DSQL Error => Encryption Salt less than 8 characters!"); - return false; - } - /** * Initialize HTTP response variable */