Fixing redirection upon user session expiration issues

revert-70aa11f8
Dileesha Rajapakse 7 years ago
parent eadb7ea02a
commit 6cff453b24

@ -67,7 +67,9 @@ deviceModule = function () {
var carbonUser = session.get(constants["USER_SESSION_KEY"]); var carbonUser = session.get(constants["USER_SESSION_KEY"]);
if (!carbonUser) { if (!carbonUser) {
log.error("User object was not found in the session"); log.error("User object was not found in the session");
throw constants["ERRORS"]["USER_NOT_FOUND"]; userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
} }
var userName = carbonUser.username + "@" + carbonUser.domain; var userName = carbonUser.username + "@" + carbonUser.domain;
var locationHistory = []; var locationHistory = [];
@ -272,7 +274,9 @@ deviceModule = function () {
); );
} else { } else {
log.error("User object was not found in the session"); log.error("User object was not found in the session");
throw constants["ERRORS"]["USER_NOT_FOUND"]; userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
} }
}; };
@ -369,7 +373,9 @@ deviceModule = function () {
var carbonUser = session.get(constants["USER_SESSION_KEY"]); var carbonUser = session.get(constants["USER_SESSION_KEY"]);
if (!carbonUser) { if (!carbonUser) {
log.error("User object was not found in the session"); log.error("User object was not found in the session");
throw constants["ERRORS"]["USER_NOT_FOUND"]; userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
} }
var userName = carbonUser.username + "@" + carbonUser.domain; var userName = carbonUser.username + "@" + carbonUser.domain;
var config = {}; var config = {};

@ -127,7 +127,9 @@ policyModule = function () {
var carbonUser = session.get(constants["USER_SESSION_KEY"]); var carbonUser = session.get(constants["USER_SESSION_KEY"]);
if (!carbonUser) { if (!carbonUser) {
log.error("User object was not found in the session"); log.error("User object was not found in the session");
throw constants["ERRORS"]["USER_NOT_FOUND"]; userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
} }
try { try {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +
@ -145,7 +147,9 @@ policyModule = function () {
var carbonUser = session.get(constants["USER_SESSION_KEY"]); var carbonUser = session.get(constants["USER_SESSION_KEY"]);
if (!carbonUser) { if (!carbonUser) {
log.error("User object was not found in the session"); log.error("User object was not found in the session");
throw constants["ERRORS"]["USER_NOT_FOUND"]; userModule.logout(function () {
response.sendRedirect(devicemgtProps["appContext"] + "login");
});
} }
try { try {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +

Loading…
Cancel
Save