From d2ec81b12b5aec44e9f5ba6d5bdfe71b930a8eda Mon Sep 17 00:00:00 2001 From: dilanua Date: Tue, 26 Jul 2016 17:35:50 +0530 Subject: [PATCH] Refactoring oauth token handling functions and dependants --- .../devicemgt/app/modules/api-wrapper-util.js | 2 +- .../devicemgt/app/modules/backend-service-invoker.js | 12 ++++++------ .../jaggeryapps/devicemgt/app/modules/util.js | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/api-wrapper-util.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/api-wrapper-util.js index 0db3225031..6c7108e3b3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/api-wrapper-util.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/api-wrapper-util.js @@ -31,7 +31,7 @@ var apiWrapperUtil = function () { log.error("Could not set up encoded tenant based client credentials " + "to session context. No username is found as input."); } else { - var dynamicClientCredentials = tokenUtil.getDyanmicClientCredentials(); + var dynamicClientCredentials = tokenUtil.getDynamicClientCredentials(); if (!dynamicClientCredentials) { log.error("Could not set up encoded tenant based client credentials " + "to session context as the server is unable to obtain dynamic client credentials."); 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 e93fe88aaa..36c9f8a075 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 @@ -43,7 +43,7 @@ var backendServiceInvoker = function () { privateMethods.getAccessToken = function () { var tokenPair = parse(session.get(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"])); if (tokenPair) { - return tokenPair.accessToken; + return tokenPair["accessToken"]; } else { return null; } @@ -78,7 +78,7 @@ var backendServiceInvoker = function () { }); } else { xmlHttpRequest. - setRequestHeader(constants["AUTHORIZATION_HEADER"], constants["BEARER_PREFIX"] + accessToken); + setRequestHeader(constants["AUTHORIZATION_HEADER"], constants["BEARER_PREFIX"] + accessToken); } } @@ -307,7 +307,7 @@ var backendServiceInvoker = function () { publicHTTPClientInvokers.get = function (url, successCallback, errorCallback) { var requestPayload = null; return privateMethods. - initiateHTTPClientRequest(constants["HTTP_GET"], url, successCallback, errorCallback, requestPayload); + initiateHTTPClientRequest(constants["HTTP_GET"], url, successCallback, errorCallback, requestPayload); }; /** @@ -319,7 +319,7 @@ var backendServiceInvoker = function () { */ publicHTTPClientInvokers.post = function (url, payload, successCallback, errorCallback) { return privateMethods. - initiateHTTPClientRequest(constants["HTTP_POST"], url, successCallback, errorCallback, payload); + initiateHTTPClientRequest(constants["HTTP_POST"], url, successCallback, errorCallback, payload); }; /** @@ -331,7 +331,7 @@ var backendServiceInvoker = function () { */ publicHTTPClientInvokers.put = function (url, payload, successCallback, errorCallback) { return privateMethods. - initiateHTTPClientRequest(constants["HTTP_PUT"], url, successCallback, errorCallback, payload); + initiateHTTPClientRequest(constants["HTTP_PUT"], url, successCallback, errorCallback, payload); }; /** @@ -343,7 +343,7 @@ var backendServiceInvoker = function () { publicHTTPClientInvokers.delete = function (url, successCallback, errorCallback) { var requestPayload = null; return privateMethods. - initiateHTTPClientRequest(constants["HTTP_DELETE"], url, successCallback, errorCallback, requestPayload); + initiateHTTPClientRequest(constants["HTTP_DELETE"], url, successCallback, errorCallback, requestPayload); }; var publicMethods = {}; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/util.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/util.js index 921850ca64..d1afc795d3 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/util.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/util.js @@ -27,7 +27,7 @@ var util = function () { var adminUser = devicemgtProps["adminUser"]; var clientName = devicemgtProps["clientName"]; - module.getDyanmicCredentials = function (owner) { + module.getDynamicClientCredentials = function () { var payload = { "callbackUrl": devicemgtProps.callBackUrl, "clientName": clientName,