Commit effdd6b9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

force logout in all tabs when user is logged out in any tab

parent 2189f352
Pipeline #11316 passed with stage
in 10 minutes and 49 seconds
......@@ -5,6 +5,8 @@ minerva (13.1.1) stable; urgency=medium
inside compartment (#856)
* Bug fix: searching for some drugs in chembl didn't provide any results even
though that data exists, for instance 'DORLIMOMAB ARITOX' (#842)
* Bug fix: user wasn't logged out in all tabs when the log out event appeard
in only one of them (#847)
-- Piotr Gawron <piotr.gawron@uni.lu> Fri, 28 Jun 2019 17:00:00 +0200
......
......@@ -99,6 +99,30 @@ ServerConnector.getMinOverlayColorInt = function () {
});
};
ServerConnector.checkIfUserLogoutFromDifferentTab = function () {
var self = this;
var sessionLogin = self.getSessionData(null).getLogin();
var tabLogin = self._currentTabLogin;
if (tabLogin === undefined) {
self._currentTabLogin = ServerConnector.getSessionData(null).getLogin();
tabLogin = self._currentTabLogin;
}
if (tabLogin !== sessionLogin) {
setTimeout(function () {
var sessionLogin = self.getSessionData(null).getLogin();
var tabLogin = self._currentTabLogin;
if (tabLogin !== sessionLogin) {
logger.warn("User was log out in different tab. Reloading page");
window.location.reload(false);
}
}, 100);
}
};
setInterval(function () {
ServerConnector.checkIfUserLogoutFromDifferentTab();
}, 1000);
ServerConnector.returnUserOrSystemColor = function (userColor, systemPromisedColor) {
return systemPromisedColor.then(function (systemColor) {
var color = userColor;
......@@ -1884,9 +1908,10 @@ ServerConnector.login = function (login, password) {
if (data["login"] !== undefined) {
params.login = data["login"];
}
self._currentTabLogin = params.login;
self.getSessionData().setLogin(params.login);
return Promise.resolve(self.getSessionData().getToken());
}, function (error) {
}).catch(function (error) {
if (error instanceof NetworkError && error.statusCode === HttpStatus.FORBIDDEN) {
throw new InvalidCredentialsError("Invalid credentials");
} else {
......@@ -2815,5 +2840,4 @@ ServerConnector.submitErrorToMinervaNet = function (report, callback) {
}, callback);
};
module.exports = ServerConnector;
......@@ -43,6 +43,10 @@ function encodeParams(params) {
return result;
}
ServerConnectorMock.checkIfUserLogoutFromDifferentTab = function () {
logger.debug("checkIfUserLogoutFromDifferentTab is ignored");
};
ServerConnectorMock._sendRequest = function (params) {
var self = this;
var url = params.url;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment