Browse Source

global

master
zeus 4 years ago
parent
commit
72f03e9f13
  1. 15
      swarmlab-app/src/run/app.js

15
swarmlab-app/src/run/app.js

@ -93,7 +93,7 @@ async function checkToken(token) {
instance.defaults.timeout = 30000; instance.defaults.timeout = 30000;
const res = await instance.post('/istokenvalidsso',params,options); const res = await instance.post('/istokenvalidsso',params,options);
if(res.status == 200){ if(res.status == 200){
console.log("check " +JSON.stringify(res.data)) //console.log("check " +JSON.stringify(res.data))
return res.data return res.data
}else{ }else{
console.log("noerror: " + res) console.log("noerror: " + res)
@ -298,6 +298,7 @@ cors(corsOptions), (req, res, next) => {
var reslog = new Object(); var reslog = new Object();
reslog.log = obj reslog.log = obj
reslog.test = usersession.SOCKET.user
//var n = {} //var n = {}
//n.year = now.getFullYear(); //n.year = now.getFullYear();
//n.month = now.getMonth(); //n.month = now.getMonth();
@ -346,9 +347,9 @@ io.on('connection', s => {
// ------------------------------ // ------------------------------
// --- set // --- set
// ------------------------------ // ------------------------------
var global = new Object(); var usersession = new Object();
global.SOCKET = {}; usersession.SOCKET = {};
global.SOCKET.error = {}; usersession.SOCKET.error = {};
console.error('socket ...'); console.error('socket ...');
s.auth = false; s.auth = false;
@ -362,9 +363,9 @@ io.on('connection', s => {
var isvalid = await checkToken(token); var isvalid = await checkToken(token);
if(isvalid.action == 'ok'){ if(isvalid.action == 'ok'){
console.log("Authserver ok ", s.id + ' - ' + token); console.log("Authserver ok ", s.id + ' - ' + token);
global.SOCKET.user = isvalid.user usersession.SOCKET.user = isvalid.user
global.SOCKET.scope = isvalid.scope // space delimeter usersession.SOCKET.scope = isvalid.scope // space delimeter
global.SOCKET.token = isvalid.token usersession.SOCKET.token = isvalid.token
s.auth = true; s.auth = true;
}else{ }else{
console.log("Authserver no ", s.id + ' - ' + token); console.log("Authserver no ", s.id + ' - ' + token);

Loading…
Cancel
Save