X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Futils%2Futils.js;h=93f8d7d838eb42d10dad07058b2e70c64bf07745;hb=04997f0db765e39bd3a1fa76d40043eda9cdd326;hp=8a54ff338a965fdcd33b8e774649a4d2c1b615fc;hpb=f07c8447b59c6fb520dca8e83c514f55116c8d5e;p=osm%2FUI.git diff --git a/skyquake/framework/utils/utils.js b/skyquake/framework/utils/utils.js index 8a54ff338..93f8d7d83 100644 --- a/skyquake/framework/utils/utils.js +++ b/skyquake/framework/utils/utils.js @@ -18,14 +18,15 @@ //Login needs to be refactored. Too many cross dependencies var AuthActions = require('../widgets/login/loginAuthActions.js'); var $ = require('jquery'); -var rw = require('utils/rw.js'); +import rw from './rw.js'; var API_SERVER = rw.getSearchParams(window.location).api_server; -let NODE_PORT = require('utils/rw.js').getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000); +let NODE_PORT = rw.getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000); var SockJS = require('sockjs-client'); var Utils = {}; Utils.DescriptorModelMeta = null; +// Utils.DescriptorModelMeta = require('./../../plugins/composer/src/src/libraries/model/DescriptorModelMeta.json'); var INACTIVITY_TIMEOUT = 600000; @@ -129,8 +130,9 @@ Utils.getDescriptorModelMeta = function() { } Utils.addAuthorizationStub = function(xhr) { - var Auth = window.sessionStorage.getItem("auth"); - xhr.setRequestHeader('Authorization', 'Basic ' + Auth); + // NO-OP now that we are dealing with it on the server + // var Auth = window.sessionStorage.getItem("auth"); + // xhr.setRequestHeader('Authorization', 'Basic ' + Auth); }; Utils.getByteDataWithUnitPrefix = function(number, precision) { @@ -183,35 +185,28 @@ Utils.getPacketDataWithUnitPrefix = function(number, precision) { } } Utils.loginHash = "#/login"; -Utils.setAuthentication = function(username, password, cb) { - var self = this; - var AuthBase64 = btoa(username + ":" + password); - window.sessionStorage.setItem("auth", AuthBase64); - self.detectInactivity(); - $.ajax({ - url: '//' + window.location.hostname + ':' + NODE_PORT + '/check-auth?api_server=' + API_SERVER, - type: 'GET', - beforeSend: Utils.addAuthorizationStub, - success: function(data) { - //console.log("LoggingSource.getLoggingConfig success call. data=", data); - if (cb) { - cb(); - }; - }, - error: function(data) { - Utils.clearAuthentication(); - } - }); -} + Utils.clearAuthentication = function(callback) { var self = this; window.sessionStorage.removeItem("auth"); AuthActions.notAuthenticated(); window.sessionStorage.setItem("locationRefHash", window.location.hash); + $.ajax({ + url: '//' + window.location.hostname + ':' + window.location.port + '/session?api_server=' + API_SERVER, + type: 'DELETE', + success: function(data) { + console.log('User logged out'); + }, + error: function(data) { + console.log('Problem logging user out'); + } + }); + + if (callback) { callback(); } else { - window.location.hash = Utils.loginHash; + window.location.replace(window.location.protocol + '//' + window.location.hostname + ':' + window.location.port + '/?api_server=' + API_SERVER); } } Utils.isNotAuthenticated = function(windowLocation, callback) {