mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
XOAUTH2 POP3
Added checking for authentication type to allow XOauth2 tokens to be sent to POP server. Turned off UI restrictions for this functionality.
This commit is contained in:
parent
7964a1e7e3
commit
0df321bcd3
@ -230,8 +230,6 @@
|
|||||||
$(".node-input-disposition").show();
|
$(".node-input-disposition").show();
|
||||||
$(".node-input-criteria").show();
|
$(".node-input-criteria").show();
|
||||||
} else {
|
} else {
|
||||||
$("#node-input-authtype").val("BASIC");
|
|
||||||
$("#node-input-authtype").change();
|
|
||||||
$(".node-input-autotls").hide();
|
$(".node-input-autotls").hide();
|
||||||
$(".node-input-box").hide();
|
$(".node-input-box").hide();
|
||||||
$(".node-input-disposition").hide();
|
$(".node-input-disposition").hide();
|
||||||
@ -250,8 +248,6 @@
|
|||||||
$(".node-input-password").hide();
|
$(".node-input-password").hide();
|
||||||
$(".node-input-saslformat").show();
|
$(".node-input-saslformat").show();
|
||||||
$(".node-input-token").show();
|
$(".node-input-token").show();
|
||||||
$("#node-input-protocol").val("IMAP"); //Remove when POP lib updated
|
|
||||||
$("#node-input-protocol").change();
|
|
||||||
$("#node-input-fetch").val("trigger");
|
$("#node-input-fetch").val("trigger");
|
||||||
$("#node-input-fetch").change();
|
$("#node-input-fetch").change();
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,6 @@ module.exports = function(RED) {
|
|||||||
if (this.authtype !== "BASIC") {
|
if (this.authtype !== "BASIC") {
|
||||||
this.inputs = 1;
|
this.inputs = 1;
|
||||||
this.repeat = 0;
|
this.repeat = 0;
|
||||||
this.protocol = "IMAP";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var flag = false;
|
var flag = false;
|
||||||
@ -275,6 +274,7 @@ module.exports = function(RED) {
|
|||||||
// the messages from the server.
|
// the messages from the server.
|
||||||
async function checkPOP3(msg,send,done) {
|
async function checkPOP3(msg,send,done) {
|
||||||
var tout = (node.repeat > 0) ? node.repeat - 500 : 15000;
|
var tout = (node.repeat > 0) ? node.repeat - 500 : 15000;
|
||||||
|
var saslxoauth2 = "";
|
||||||
var currentMessage = 1;
|
var currentMessage = 1;
|
||||||
var maxMessage = 0;
|
var maxMessage = 0;
|
||||||
var nextMessage;
|
var nextMessage;
|
||||||
@ -288,9 +288,23 @@ 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") {
|
||||||
|
var value = RED.util.getMessageProperty(msg,node.token);
|
||||||
|
if (value !== undefined) {
|
||||||
|
if(node.saslformat) {
|
||||||
|
//Make base64 string for access - compatible with outlook365 and gmail
|
||||||
|
saslxoauth2 = Buffer.from("user="+node.userid+"\x01auth=Bearer "+value+"\x01\x01").toString('base64');
|
||||||
|
} else {
|
||||||
|
saslxoauth2 = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await pop3.command('AUTH', "XOAUTH2");
|
||||||
|
await pop3.command(saslxoauth2);
|
||||||
|
|
||||||
|
} 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);
|
||||||
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
node.error(err.message,err);
|
node.error(err.message,err);
|
||||||
node.status({fill:"red",shape:"ring",text:"email.status.connecterror"});
|
node.status({fill:"red",shape:"ring",text:"email.status.connecterror"});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user