mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Fix defaulting of email auth value (and linting)
This commit is contained in:
parent
9a57958a1e
commit
8320571630
@ -54,7 +54,7 @@
|
|||||||
<label for="node-input-password"><i class="fa fa-lock"></i> <span data-i18n="email.label.password"></span></label>
|
<label for="node-input-password"><i class="fa fa-lock"></i> <span data-i18n="email.label.password"></span></label>
|
||||||
<input type="password" id="node-input-password">
|
<input type="password" id="node-input-password">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row node-input-saslformat" style="display: none;">
|
<div class="form-row node-input-saslformat" style="display: none;">
|
||||||
<label for="node-input-saslformat"><i class="fa fa-code"></i> <span data-i18n="email.label.saslformat"></span></label>
|
<label for="node-input-saslformat"><i class="fa fa-code"></i> <span data-i18n="email.label.saslformat"></span></label>
|
||||||
<input type="checkbox" id="node-input-saslformat" style="width: auto;">
|
<input type="checkbox" id="node-input-saslformat" style="width: auto;">
|
||||||
@ -127,6 +127,10 @@
|
|||||||
return (this.dname)?"node_label_italic":"";
|
return (this.dname)?"node_label_italic":"";
|
||||||
},
|
},
|
||||||
oneditprepare: function() {
|
oneditprepare: function() {
|
||||||
|
if (this.authtype === undefined) {
|
||||||
|
this.authtype = "BASIC";
|
||||||
|
$("#node-input-authtype").val('BASIC');
|
||||||
|
}
|
||||||
if (this.credentials.global) {
|
if (this.credentials.global) {
|
||||||
$('#node-tip').show();
|
$('#node-tip').show();
|
||||||
} else {
|
} else {
|
||||||
@ -335,6 +339,10 @@
|
|||||||
},
|
},
|
||||||
oneditprepare: function() {
|
oneditprepare: function() {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
if (this.authtype === undefined) {
|
||||||
|
this.authtype = "BASIC";
|
||||||
|
$("#node-input-authtype").val('BASIC');
|
||||||
|
}
|
||||||
if (this.credentials.global) {
|
if (this.credentials.global) {
|
||||||
$('#node-tip').show();
|
$('#node-tip').show();
|
||||||
} else {
|
} else {
|
||||||
@ -388,22 +396,22 @@
|
|||||||
<label style="width:40px"> </label>
|
<label style="width:40px"> </label>
|
||||||
<input type="checkbox" id="node-input-secure" style="display:inline-block; width:20px; vertical-align:baseline;">
|
<input type="checkbox" id="node-input-secure" style="display:inline-block; width:20px; vertical-align:baseline;">
|
||||||
<span data-i18n="email.label.enableSecure"></span>
|
<span data-i18n="email.label.enableSecure"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-starttls"><i class="fa fa-lock"></i> <span data-i18n="email.label.enableStarttls"></span></label>
|
<label for="node-input-starttls"><i class="fa fa-lock"></i> <span data-i18n="email.label.enableStarttls"></span></label>
|
||||||
<input type="checkbox" id="node-input-starttls" style="display:inline-block; width:20px; vertical-align:baseline;">
|
<input type="checkbox" id="node-input-starttls" style="display:inline-block; width:20px; vertical-align:baseline;">
|
||||||
<span data-i18n="email.label.starttlsUpgrade"></span>
|
<span data-i18n="email.label.starttlsUpgrade"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row" id="certRow">
|
<div class="form-row" id="certRow">
|
||||||
<label for="node-input-certFile"><i class="fa fa-file"></i>
|
<label for="node-input-certFile"><i class="fa fa-file"></i>
|
||||||
<span data-i18n="email.label.certFile"></span></label>
|
<span data-i18n="email.label.certFile"></span></label>
|
||||||
<input type="text" id="node-input-certFile" placeholder="server.crt" style="width:100%">
|
<input type="text" id="node-input-certFile" placeholder="server.crt" style="width:100%">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row" id="keyRow">
|
<div class="form-row" id="keyRow">
|
||||||
<label for="node-input-keyFile"><i class="fa fa-key"></i>
|
<label for="node-input-keyFile"><i class="fa fa-key"></i>
|
||||||
<span data-i18n="email.label.keyFile"></span></label>
|
<span data-i18n="email.label.keyFile"></span></label>
|
||||||
<input type="text" id="node-input-keyFile" placeholder="private.key" style="width:100%">
|
<input type="text" id="node-input-keyFile" placeholder="private.key" style="width:100%">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-auth"><i class="fa fa-user"></i> <span data-i18n="email.label.users"></span></label>
|
<label for="node-input-auth"><i class="fa fa-user"></i> <span data-i18n="email.label.users"></span></label>
|
||||||
<input type="checkbox" id="node-input-auth" style="display:inline-block; width:20px; vertical-align:baseline;">
|
<input type="checkbox" id="node-input-auth" style="display:inline-block; width:20px; vertical-align:baseline;">
|
||||||
@ -424,7 +432,7 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-expert"><i class="fa fa-cog"></i> <span data-i18n="email.label.expert"></span></label>
|
<label for="node-input-expert"><i class="fa fa-cog"></i> <span data-i18n="email.label.expert"></span></label>
|
||||||
<input type="text" id="node-input-expert">
|
<input type="text" id="node-input-expert">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
||||||
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
||||||
@ -545,7 +553,7 @@
|
|||||||
$("#node-input-email-users-container-div").scrollTop(
|
$("#node-input-email-users-container-div").scrollTop(
|
||||||
$("#node-input-email-users-container-div").get(0).scrollHeight
|
$("#node-input-email-users-container-div").get(0).scrollHeight
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
$("#node-input-auth").change(function () {
|
$("#node-input-auth").change(function () {
|
||||||
if ($("#node-input-auth").is(":checked")) {
|
if ($("#node-input-auth").is(":checked")) {
|
||||||
$("#node-input-email-users-add").show();
|
$("#node-input-email-users-add").show();
|
||||||
@ -554,12 +562,12 @@
|
|||||||
$("#node-input-email-users-add").hide();
|
$("#node-input-email-users-add").hide();
|
||||||
$("#node-input-email-users-container-div").hide();
|
$("#node-input-email-users-container-div").hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Expert settings
|
// Expert settings
|
||||||
$("#node-input-expert").typedInput({
|
$("#node-input-expert").typedInput({
|
||||||
type: "json",
|
type: "json",
|
||||||
types: ["json"]
|
types: ["json"]
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
oneditsave: function () {
|
oneditsave: function () {
|
||||||
let node = this;
|
let node = this;
|
||||||
|
@ -57,7 +57,7 @@ module.exports = function(RED) {
|
|||||||
this.error(RED._("email.errors.nouserid"));
|
this.error(RED._("email.errors.nouserid"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.authtype === "BASIC" ) {
|
if (this.authtype === "BASIC" ) {
|
||||||
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
||||||
this.password = this.credentials.password;
|
this.password = this.credentials.password;
|
||||||
} else {
|
} else {
|
||||||
@ -88,8 +88,8 @@ module.exports = function(RED) {
|
|||||||
secure: node.secure,
|
secure: node.secure,
|
||||||
tls: {rejectUnauthorized: node.tls}
|
tls: {rejectUnauthorized: node.tls}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(node.authtype === "BASIC" ) {
|
if (node.authtype === "BASIC" ) {
|
||||||
smtpOptions.auth = {
|
smtpOptions.auth = {
|
||||||
user: node.userid,
|
user: node.userid,
|
||||||
pass: node.password
|
pass: node.password
|
||||||
@ -252,7 +252,7 @@ module.exports = function(RED) {
|
|||||||
this.error(RED._("email.errors.nouserid"));
|
this.error(RED._("email.errors.nouserid"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.authtype === "BASIC" ) {
|
if (this.authtype === "BASIC" ) {
|
||||||
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
||||||
this.password = this.credentials.password;
|
this.password = this.credentials.password;
|
||||||
} else {
|
} else {
|
||||||
@ -311,7 +311,7 @@ module.exports = function(RED) {
|
|||||||
var currentMessage = 1;
|
var currentMessage = 1;
|
||||||
var maxMessage = 0;
|
var maxMessage = 0;
|
||||||
var nextMessage;
|
var nextMessage;
|
||||||
|
|
||||||
pop3 = new Pop3Command({
|
pop3 = new Pop3Command({
|
||||||
"host": node.inserver,
|
"host": node.inserver,
|
||||||
"tls": node.useSSL,
|
"tls": node.useSSL,
|
||||||
@ -321,10 +321,10 @@ module.exports = function(RED) {
|
|||||||
try {
|
try {
|
||||||
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
|
||||||
await pop3.connect();
|
await pop3.connect();
|
||||||
if(node.authtype == "XOAUTH2") {
|
if (node.authtype == "XOAUTH2") {
|
||||||
var value = RED.util.getMessageProperty(msg,node.token);
|
var value = RED.util.getMessageProperty(msg,node.token);
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if(node.saslformat) {
|
if (node.saslformat) {
|
||||||
//Make base64 string for access - compatible with outlook365 and gmail
|
//Make base64 string for access - compatible with outlook365 and gmail
|
||||||
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
||||||
} else {
|
} else {
|
||||||
@ -334,7 +334,7 @@ module.exports = function(RED) {
|
|||||||
await pop3.command('AUTH', "XOAUTH2");
|
await pop3.command('AUTH', "XOAUTH2");
|
||||||
await pop3.command(saslxoauth2);
|
await pop3.command(saslxoauth2);
|
||||||
|
|
||||||
} else if(node.authtype == "BASIC") {
|
} else if (node.authtype == "BASIC") {
|
||||||
await pop3.command('USER', node.userid);
|
await pop3.command('USER', node.userid);
|
||||||
await pop3.command('PASS', node.password);
|
await pop3.command('PASS', node.password);
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ module.exports = function(RED) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
maxMessage = (await pop3.STAT()).split(" ")[0];
|
maxMessage = (await pop3.STAT()).split(" ")[0];
|
||||||
if(maxMessage>0) {
|
if (maxMessage>0) {
|
||||||
node.status({fill:"blue", shape:"dot", text:"email.status.fetching"});
|
node.status({fill:"blue", shape:"dot", text:"email.status.fetching"});
|
||||||
while(currentMessage<=maxMessage) {
|
while(currentMessage<=maxMessage) {
|
||||||
try {
|
try {
|
||||||
@ -401,10 +401,10 @@ module.exports = function(RED) {
|
|||||||
function checkIMAP(msg,send,done) {
|
function checkIMAP(msg,send,done) {
|
||||||
var tout = (node.repeat > 0) ? node.repeat - 500 : 15000;
|
var tout = (node.repeat > 0) ? node.repeat - 500 : 15000;
|
||||||
var saslxoauth2 = "";
|
var saslxoauth2 = "";
|
||||||
if(node.authtype == "XOAUTH2") {
|
if (node.authtype == "XOAUTH2") {
|
||||||
var value = RED.util.getMessageProperty(msg,node.token);
|
var value = RED.util.getMessageProperty(msg,node.token);
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if(node.saslformat) {
|
if (node.saslformat) {
|
||||||
//Make base64 string for access - compatible with outlook365 and gmail
|
//Make base64 string for access - compatible with outlook365 and gmail
|
||||||
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user