【发布时间】:2015-03-06 00:15:38
【问题描述】:
IBM MobileFirst v.6.3 中 ChallengeHandler 的 submitAdapterAuthentication() 方法存在问题。
我们将回调函数分配给the options object 中的属性“onSuccess”和“onFailure”。
然后我们将 options 对象提供给 submitAdapterAuthentication(invocationData, options) 并执行它。
var ch = WL.Client.createChallengeHandler(securityTest);
//////////////////
function login (user, pass) {
tempUser = {username: user, password: pass};
userObj.user = user;
var auth = "Basic " + window.btoa(user + ":" + pass);
var invocationData = {
parameters: [auth, user],
adapter: "SingleStepAuthAdapter",
procedure: "submitLogin"
};
var options = {
onSuccess: iWon,
onFailure: iLost,
invocationContext: {invocationData: invocationData},
timeout: 10000
};
ch.submitAdapterAuthentication(invocationData, options);
});
function iWon(response) {
WL.Logger.debug('Login success! Response: ' + JSON.stringify(response));
//update user info, as somehow isUserAuthenticated return false without it
WL.Client.updateUserInfo(function(response) {
WL.Logger.debug('Updated User Info success! Response: ' + JSON.stringify(response));
});
}
function iLost(response) {
WL.Logger.debug('ERROR. Login failed! Response: ' + JSON.stringify(response));
}
在执行 submitAdapterAuthentication(invocationData, options) 后不会调用 onSuccess (iWon) 或 onFailure (iLost)。
我们如何知道认证是否成功?
我们应该寻找和使用哪些选项、事件、回调或承诺?
我们也在此处发布了该问题: submitAdapterAuthentication not working
【问题讨论】:
-
是完整的JS代码吗?你错过了
ch.isCustomResponse = function(response){...}和ch.handleChallenge = function(response){...} -
"我们也在这里发布了问题" - 是同一个问题吗?
-
他们发布了这个问题作为答案(可能很快就会被删除)
标签: callback ibm-mobilefirst promise