From 6cff453b24d1df62d33eb85557a57728b218b7d2 Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 18 Jul 2017 09:46:04 +0530 Subject: [PATCH] Fixing redirection upon user session expiration issues --- .../app/modules/business-controllers/device.js | 12 +++++++++--- .../app/modules/business-controllers/policy.js | 8 ++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js index 0300b99e183..308c6b7c80b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/device.js @@ -67,7 +67,9 @@ deviceModule = function () { var carbonUser = session.get(constants["USER_SESSION_KEY"]); if (!carbonUser) { 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 locationHistory = []; @@ -272,7 +274,9 @@ deviceModule = function () { ); } else { 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"]); if (!carbonUser) { 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 config = {}; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js index 792d1243ff1..73f539562cc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/policy.js @@ -127,7 +127,9 @@ policyModule = function () { var carbonUser = session.get(constants["USER_SESSION_KEY"]); if (!carbonUser) { 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 { var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + @@ -145,7 +147,9 @@ policyModule = function () { var carbonUser = session.get(constants["USER_SESSION_KEY"]); if (!carbonUser) { 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 { var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] +