mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Stop lost connection message bouncing when not authed
This commit is contained in:
parent
9bbe0799bd
commit
f5d7903ecb
@ -17,6 +17,8 @@
|
|||||||
RED.comms = (function() {
|
RED.comms = (function() {
|
||||||
|
|
||||||
var errornotification = null;
|
var errornotification = null;
|
||||||
|
var clearErrorTimer = null;
|
||||||
|
|
||||||
var subscriptions = {};
|
var subscriptions = {};
|
||||||
var ws;
|
var ws;
|
||||||
function connectWS() {
|
function connectWS() {
|
||||||
@ -26,8 +28,10 @@ RED.comms = (function() {
|
|||||||
ws = new WebSocket(path);
|
ws = new WebSocket(path);
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
if (errornotification) {
|
if (errornotification) {
|
||||||
|
clearErrorTimer = setTimeout(function() {
|
||||||
errornotification.close();
|
errornotification.close();
|
||||||
errornotification = null;
|
errornotification = null;
|
||||||
|
},1000);
|
||||||
}
|
}
|
||||||
var auth_tokens = RED.settings.get("auth-tokens");
|
var auth_tokens = RED.settings.get("auth-tokens");
|
||||||
if (auth_tokens) {
|
if (auth_tokens) {
|
||||||
@ -60,6 +64,9 @@ RED.comms = (function() {
|
|||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
if (errornotification == null) {
|
if (errornotification == null) {
|
||||||
errornotification = RED.notify("<b>Error</b>: Lost connection to server","error",true);
|
errornotification = RED.notify("<b>Error</b>: Lost connection to server","error",true);
|
||||||
|
} else if (clearErrorTimer) {
|
||||||
|
clearTimeout(clearErrorTimer);
|
||||||
|
clearErrorTimer = null;
|
||||||
}
|
}
|
||||||
setTimeout(connectWS,1000);
|
setTimeout(connectWS,1000);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ var bearerStrategy = function (accessToken, done) {
|
|||||||
Tokens.get(accessToken).then(function(token) {
|
Tokens.get(accessToken).then(function(token) {
|
||||||
if (token) {
|
if (token) {
|
||||||
Users.get(token.user).then(function(user) {
|
Users.get(token.user).then(function(user) {
|
||||||
console.log(user);
|
|
||||||
if (user) {
|
if (user) {
|
||||||
done(null,{username:user.username},{scope:token.scope});
|
done(null,{username:user.username},{scope:token.scope});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user