diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/backend-service-invoker.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/backend-service-invoker.js index 1e374b434d3..e93fe88aaac 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/backend-service-invoker.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/backend-service-invoker.js @@ -41,7 +41,7 @@ var backendServiceInvoker = function () { * If the token pair s not set in the session this will send a redirect to the login page. */ privateMethods.getAccessToken = function () { - var tokenPair = session.get(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"]); + var tokenPair = parse(session.get(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"])); if (tokenPair) { return tokenPair.accessToken; } else { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js index 038082c50c7..eeeb81ba5ef 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/login.js @@ -23,20 +23,17 @@ var onFail; var log = new Log("/app/modules/login.js"); var constants = require("/app/modules/constants.js"); onSuccess = function (context) { - var properties; var utility = require("/app/modules/utility.js").utility; var apiWrapperUtil = require("/app/modules/api-wrapper-util.js").apiWrapperUtil; if (context.input.samlToken) { - properties = {samlToken: context.input.samlToken}; - apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_SAML, properties); + apiWrapperUtil.setupAccessTokenPairBySamlGrantType(context.input.username, context.input.samlToken); } else { - properties = {username: context.input.username, password: context.input.password}; - apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_PASSWORD, properties); + apiWrapperUtil.setupAccessTokenPairByPasswordGrantType(context.input.username, context.input.password); } var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; var carbonServer = require("carbon").server; (new carbonServer.Server({url: devicemgtProps["adminService"]})) - .login(context.input.username, context.input.password); + .login(context.input.username, context.input.password); }; onFail = function (error) {