Skip to content
Permalink
Browse files

reload page when auth needed and ajax request

  • Loading branch information...
TothiViseo committed Aug 19, 2019
1 parent e6ad429 commit 5850ee3c98ee607b5785e9ed1bcdb92ce66e48f1
Showing with 7 additions and 1 deletion.
  1. +6 −0 node-red-viseo-middleware/index.js
  2. +1 −1 node-red-viseo-middleware/package.json
@@ -74,14 +74,20 @@ module.exports = function() {
//get access token
let scope = requestedUrl.match(scopeTest)[1];
let ssid = req.cookies[scope];

if(ssid) {
if(AUTHORIZED_TOKENS[ssid] && AUTHORIZED_TOKENS[ssid].expires > Date.now()) {
return next();
} else {
delete AUTHORIZED_TOKENS[ssid];
if(req.headers["x-requested-with"] === "XMLHttpRequest") {
res.sendStatus(401);
}
}
}



//check access token

var template = fs.readFileSync(path.join(__dirname, "template","login.html"),"utf8");
@@ -1,6 +1,6 @@
{
"name": "node-red-viseo-middleware",
"version": "0.0.5",
"version": "0.1.0",
"description": "Middleware for node-red http in",
"dependencies": {
"mustache":"^2.3.0",

0 comments on commit 5850ee3

Please sign in to comment.
You can’t perform that action at this time.