|
|
@ -23,20 +23,17 @@ 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;
|
|
|
|
(new carbonServer.Server({url: devicemgtProps["adminService"]}))
|
|
|
|
(new carbonServer.Server({url: devicemgtProps["adminService"]}))
|
|
|
|
.login(context.input.username, context.input.password);
|
|
|
|
.login(context.input.username, context.input.password);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onFail = function (error) {
|
|
|
|
onFail = function (error) {
|
|
|
|