如何使用Web服务验证Worklight基于Adapter的身份验证中的用户名和密码?
问题描述:
singleStepAuthRealmChallengeHandler.handleChallenge = function(response){
var authRequired = response.responseJSON.authRequired;
user_id=response.responseJSON.loginUser;
if (authRequired == true){
$("#AppDiv").hide();
$("#AuthDiv").show();
$("#AuthPassword").empty();
$("#AuthInfo").empty();
if (response.responseJSON.errorMessage){
$("#AuthInfo").html(response.responseJSON.errorMessage);
}
} else if (authRequired == false){
$('#AuthSubmitButton').attr('href','home.html');
$("#AuthSubmitButton").click();
$("#AuthSubmitButton").click();
singleStepAuthRealmChallengeHandler.submitSuccess();
}};
$("#AuthSubmitButton").bind('click', function() {
var username = $("#AuthUsername").val();
var password = $("#AuthPassword").val();
var invocationData = {
adapter : "SingleStepAuthAdapter",
procedure : "verifyLogin",
parameters : [ username, password ]
};
var options= {
onSuccess: success,
onFailure: failure`enter code here`
};
WL.Client.invokeProcedure(invocationData, options);});
function success(response)
{
var result=JSON.stringify(response);
var invocationData = {
adapter : "SingleStepAuthAdapter",
procedure : "submitAuthentication",
parameters : [ result ]
};
singleStepAuthRealmChallengeHandler.submitAdapterAuthentication(invocationData, {});}
这种方法是否正确?当用户登录时它不工作,不会重定向到主页。 :-(如何使用Web服务验证Worklight基于Adapter的身份验证中的用户名和密码?
这里首先我试图调用过程获取用户名密码从服务器和成功函数我打电话提交身份验证,但当用户登录,下次我访问安全过程时,它不重定向直接主页,而不是,它说用户已经在其登录假设运行得到authrequired = false,并转到主页。
我使用REST API的来获取用户名和密码,并传递给submitauthentication
功能。
是否因为调用两次有问题我不能找出来请帮忙。
得到了解决方案很简单:-) – 2014-09-20 19:59:20