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 0300b99e18..6c67dfa4f2 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 = []; @@ -261,7 +263,9 @@ deviceModule = function () { url, function (responsePayload) { if(!responsePayload["responseText"]){ log.error("Error while fetching device count. API `" + url + "` returns HTTP: " + responsePayload["status"]); - throw constants["ERRORS"]["UNKNOWN_ERROR"]; + userModule.logout(function () { + response.sendRedirect(devicemgtProps["appContext"] + "login"); + }); } return parse(responsePayload["responseText"])["count"]; }, @@ -272,7 +276,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"); + }); } }; @@ -300,7 +306,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 +377,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/group.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js index 82ecb1ae3d..348251622f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/business-controllers/group.js @@ -41,7 +41,9 @@ var groupModule = {}; } else { if (!user) { log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; + userModule.logout(function () { + response.sendRedirect(devicemgtProps["appContext"] + "login"); + }); } log.error("Access denied for user: " + user.username); return -1; 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 792d1243ff..73f539562c 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"] +