From 4c1fb558d30e142cc4198f6ee2c312c5b29a8d9d Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Tue, 6 Dec 2016 10:50:46 +0530 Subject: [PATCH] Fixing sso infinite redirection --- .../app/pages/cdmf.page.sign-in/sign-in.hbs | 5 +++- .../app/pages/cdmf.page.sign-in/sign-in.js | 28 +++++++++++++++++++ .../app/pages/cdmf.page.sign-in/sign-in.json | 3 +- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.js diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs index 105c65ac6d..a7f39044dc 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.hbs @@ -31,7 +31,7 @@ {{/if}}
-
+
+ {{#if sessionDataKey}} + + {{/if}} {{#if referer}} {{/if}} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.js new file mode 100644 index 0000000000..df49bf1d04 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.js @@ -0,0 +1,28 @@ +function onRequest(context) { + var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var authModuleConfigs = context.app.conf["authModule"]; + var sessionDataKey = request.getParameter("sessionDataKey"); + + //if sso enabled and sessionDataKey is empty redirect + var ssoConfigs = authModuleConfigs["sso"]; + if (ssoConfigs && (ssoConfigs["enabled"].toString() == "true") && !sessionDataKey) { + // SSO is enabled in Auth module. + var redirectUri = context.app.context + "/uuf/login"; + var queryString = request.getQueryString(); + if (queryString && (queryString.length > 0)) { + redirectUri = redirectUri + "?" + queryString; + } + response.sendRedirect(encodeURI(redirectUri)); + exit(); + } + + var viewModel = {}; + var loginActionUrl = context.app.context + "/uuf/login"; + if (sessionDataKey) { + loginActionUrl = devicemgtProps["httpsURL"] + "/commonauth"; + } + + viewModel.sessionDataKey = sessionDataKey; + viewModel.loginActionUrl = loginActionUrl; + return viewModel; +} \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.json b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.json index 58846893fc..91d4a819bd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.json +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.sign-in/sign-in.json @@ -1,5 +1,6 @@ { "version": "1.0.0", + "layout": "uuf.layout.sign-in", "uri": "/login", - "extends": "uuf.page.sign-in" + "isAnonymous": true } \ No newline at end of file