Refactoring oauth token handling functions and dependants

revert-70aa11f8
dilanua 8 years ago
parent 2e5d046fbf
commit c228f03481

@ -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. * If the token pair s not set in the session this will send a redirect to the login page.
*/ */
privateMethods.getAccessToken = function () { privateMethods.getAccessToken = function () {
var tokenPair = session.get(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"]); var tokenPair = parse(session.get(constants["ACCESS_TOKEN_PAIR_IDENTIFIER"]));
if (tokenPair) { if (tokenPair) {
return tokenPair.accessToken; return tokenPair.accessToken;
} else { } else {

@ -23,15 +23,12 @@ var onFail;
var log = new Log("/app/modules/login.js"); var log = new Log("/app/modules/login.js");
var constants = require("/app/modules/constants.js"); var constants = require("/app/modules/constants.js");
onSuccess = function (context) { onSuccess = function (context) {
var properties;
var utility = require("/app/modules/utility.js").utility; var utility = require("/app/modules/utility.js").utility;
var apiWrapperUtil = require("/app/modules/api-wrapper-util.js").apiWrapperUtil; var apiWrapperUtil = require("/app/modules/api-wrapper-util.js").apiWrapperUtil;
if (context.input.samlToken) { if (context.input.samlToken) {
properties = {samlToken: context.input.samlToken}; apiWrapperUtil.setupAccessTokenPairBySamlGrantType(context.input.username, context.input.samlToken);
apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_SAML, properties);
} else { } else {
properties = {username: context.input.username, password: context.input.password}; apiWrapperUtil.setupAccessTokenPairByPasswordGrantType(context.input.username, context.input.password);
apiWrapperUtil.setupAccessTokenPair(constants.GRANT_TYPE_PASSWORD, properties);
} }
var devicemgtProps = require("/app/conf/reader/main.js")["conf"]; var devicemgtProps = require("/app/conf/reader/main.js")["conf"];
var carbonServer = require("carbon").server; var carbonServer = require("carbon").server;

Loading…
Cancel
Save