Error reporting

Password missing error only occurs if set to basic authentication.

Token missing only occurs if set to XOAuth2.
This commit is contained in:
wooferguy 2023-02-09 19:47:37 +13:00
parent aea1407745
commit b433ed55f0
2 changed files with 17 additions and 9 deletions

View File

@ -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) {

View File

@ -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",