Refactoring oauth token handling functions and dependants

4.x.x
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.
*/
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 {

@ -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) {

Loading…
Cancel
Save