X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fframework%2Futils%2Futils.js;h=be3278d088237236ab325796c4c80e505f28741f;hb=3d39b18290b9cb3e10c1a80d91ac4819e7c58474;hp=3d84f4b5cb10ba0aa96836cedbcdf69e3da3670f;hpb=b78fbe20fd7d976b3e15abb2387b4e329a5ea918;p=osm%2FUI.git diff --git a/skyquake/framework/utils/utils.js b/skyquake/framework/utils/utils.js index 3d84f4b5c..be3278d08 100644 --- a/skyquake/framework/utils/utils.js +++ b/skyquake/framework/utils/utils.js @@ -20,7 +20,7 @@ var AuthActions = require('../widgets/login/loginAuthActions.js'); var $ = require('jquery'); var rw = require('utils/rw.js'); var API_SERVER = rw.getSearchParams(window.location).api_server; -var NODE_PORT = 8000; +let NODE_PORT = require('utils/rw.js').getSearchParams(window.location).api_port || ((window.location.protocol == 'https:') ? 8443 : 8000); var SockJS = require('sockjs-client'); var Utils = {}; @@ -129,8 +129,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) { @@ -189,7 +190,7 @@ Utils.setAuthentication = function(username, password, cb) { window.sessionStorage.setItem("auth", AuthBase64); self.detectInactivity(); $.ajax({ - url: '//' + window.location.hostname + ':' + NODE_PORT + '/check-auth?api_server=' + API_SERVER, + url: '//' + window.location.hostname + ':' + window.location.port + '/check-auth?api_server=' + API_SERVER, type: 'GET', beforeSend: Utils.addAuthorizationStub, success: function(data) { @@ -208,10 +209,22 @@ Utils.clearAuthentication = function(callback) { 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) { @@ -295,4 +308,20 @@ Utils.arrayIntersperse = (arr, sep) => { }, [arr[0]]); } +Utils.cleanImageDataURI = (imageString, type, id) => { + if (/\bbase64\b/g.test(imageString)) { + return imageString; + } else if (/<\?xml\b/g.test(imageString)) { + const imgStr = imageString.substring(imageString.indexOf('