From b433ed55f0bbaa89a5c5807b816c97c91ded83bc Mon Sep 17 00:00:00 2001 From: wooferguy Date: Thu, 9 Feb 2023 19:47:37 +1300 Subject: [PATCH] Error reporting Password missing error only occurs if set to basic authentication. Token missing only occurs if set to XOAuth2. --- social/email/61-email.js | 25 +++++++++++++++--------- social/email/locales/en-US/61-email.json | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/social/email/61-email.js b/social/email/61-email.js index 30c2ec0b..678de660 100644 --- a/social/email/61-email.js +++ b/social/email/61-email.js @@ -196,9 +196,7 @@ module.exports = function(RED) { this.inport = n.port || (globalkeys && globalkeys.port) || "993"; this.box = n.box || "INBOX"; this.useSSL= n.useSSL; - this.saslformat = n.saslformat; this.autotls= n.autotls; - this.token = n.token || "oAuth2Response.access_token"; this.protocol = n.protocol || "IMAP"; this.disposition = n.disposition || "None"; // "None", "Delete", "Read" this.criteria = n.criteria || "UNSEEN"; // "ALL", "ANSWERED", "FLAGGED", "SEEN", "UNANSWERED", "UNFLAGGED", "UNSEEN" @@ -216,14 +214,23 @@ module.exports = function(RED) { this.error(RED._("email.errors.nouserid")); } } - if (this.credentials && this.credentials.hasOwnProperty("password")) { - this.password = this.credentials.password; - } else { - if (globalkeys) { - this.password = globalkeys.pass; - flag = true; + if(this.authtype === "BASIC" ) { + if (this.credentials && this.credentials.hasOwnProperty("password")) { + this.password = this.credentials.password; } else { - this.error(RED._("email.errors.nopassword")); + if (globalkeys) { + this.password = globalkeys.pass; + flag = true; + } else { + this.error(RED._("email.errors.nopassword")); + } + } + } else { + this.saslformat = n.saslformat; + if(n.token!=="") { + this.token = n.token; + } else { + this.error(RED._("email.errors.notoken")); } } if (flag) { diff --git a/social/email/locales/en-US/61-email.json b/social/email/locales/en-US/61-email.json index 005b0098..d825cb44 100644 --- a/social/email/locales/en-US/61-email.json +++ b/social/email/locales/en-US/61-email.json @@ -72,6 +72,7 @@ "errors": { "nouserid": "No e-mail userid set", "nopassword": "No e-mail password set", + "notoken": "No token property set", "nocredentials": "No Email credentials found. See info panel.", "nosmtptransport": "No SMTP transport. See info panel.", "nopayload": "No payload to send",