From 84492d70acdab0794de247d015c8ee139e127e66 Mon Sep 17 00:00:00 2001 From: GPrathap Date: Wed, 20 Apr 2016 22:10:04 +0530 Subject: [PATCH] added constants for authentications types --- .../jaggeryapps/devicemgt/app/modules/api-wrapper-util.js | 7 ++++--- .../jaggeryapps/devicemgt/app/modules/constants.js | 7 +++++-- 2 files changed, 9 insertions(+), 5 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 76474fb098..1a518bcf22 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 @@ -20,6 +20,7 @@ var apiWrapperUtil = function () { var module = {}; var tokenUtil = require("/app/modules/util.js").util; var constants = require("/app/modules/constants.js"); + var constants = require("/app/modules/constants.js"); module.refreshToken = function () { var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER); @@ -32,12 +33,12 @@ var apiWrapperUtil = function () { var clientData = tokenUtil.getDyanmicCredentials(properties); var encodedClientKeys = tokenUtil.encode(clientData.clientId + ":" + clientData.clientSecret); session.put(constants.ENCODED_CLIENT_KEYS_IDENTIFIER, encodedClientKeys); - if (type == "password") { + if (type == constants.GRANT_TYPE_PASSWORD) { tokenPair = tokenUtil.getTokenWithPasswordGrantType(properties.username, encodeURIComponent(properties.password), encodedClientKeys); - } else if (type == "saml") { + } else if (type == constants.GRANT_TYPE_SAML) { tokenPair = tokenUtil. - getTokenWithSAMLGrantType(properties.samlToken, encodedClientKeys, "PRODUCTION"); + getTokenWithSAMLGrantType(properties.samlToken, encodedClientKeys, "PRODUCTION"); } session.put(constants.ACCESS_TOKEN_PAIR_IDENTIFIER, tokenPair); }; diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js index f5a5b83348..9e2d1469fb 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/modules/constants.js @@ -48,8 +48,8 @@ var LANGUAGE_US = "en_US"; var VENDOR_APPLE = "Apple"; var ERRORS = { - "USER_NOT_FOUND": "USER_NOT_FOUND" - }; + "USER_NOT_FOUND": "USER_NOT_FOUND" +}; var USER_STORES_NOISY_CHAR = "\""; var USER_STORES_SPLITTING_CHAR = "\\n"; @@ -70,6 +70,9 @@ var HTTP_POST = "POST"; var HTTP_PUT = "PUT"; var HTTP_DELETE = "DELETE"; +var GRANT_TYPE_PASSWORD = "password"; +var GRANT_TYPE_SAML = "saml"; + var MQTT_QUEUE_CONFIG_NAME = "MQTT"; var HTTP_CONFLICT = 409;