我已关注This Link
哪个对我有用。我在所有这三个适配器中有3个适配器我使用相同的安全测试领域进行所有程序。在我提供的某些超时后,适配器返回我登录失败,这是正确的。但是在应用程序超时后我收到了以下错误 -
控制台错误 - AUTHENTICATION_ERROR,错误消息:使用loginModule执行身份验证时发生错误AdapterAuthLoginModule,用户身份不可用。
应用程序错误 - handler.handleFailure不是函数
我无法在worklight.js
中获得上述错误导致此错误的原因是什么?我想在超时后调用注销功能。但由于上述错误,我无法打电话。
adapter.xml
<wl:adapter xmlns:wl="http://www.worklight.com/integration" xmlns:http="http://www.worklight.com/integration/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="AuthenticationAdapter">
<displayName>AuthenticationAdapter</displayName>
<description>AuthenticationAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>rss.cnn.com</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2"/>
</connectivity>
<procedure name="submitAuthentication"/>
<procedure name="getSecretData" securityTest="AuthenticationAdapter-securityTest"/>
</wl:adapter>
adapterAuthRealmChallengeHandler.js
adapterAuthRealmChallengeHandler.isCustomResponse = function(response) {
if (!response || !response.responseJSON || response.responseText === null) {
return false;
}
if (typeof(response.responseJSON.authRequired) !== 'undefined'){
return true;
} else {
return false;
}
};
adapterAuthRealmChallengeHandler.handleChallenge = function(response){
var authRequired = response.responseJSON.authRequired;
if (authRequired == true){
navigator.notification.alert("Your session has timed out!");
logoutfunction(); //logout function call
} else if (authRequired == false){
if(CurrentSessionId == "" || CurrentSessionId == null){
logoutfunction(); //logout function call
}
else{
var invocationData = {
adapter : "API_Adapter",
procedure : "storeSession",
parameters : [userID],
compressResponse : true
};
WL.Client.invokeProcedure(invocationData, {
onSuccess : function Lsuccess(res){},
onFailure : function Lfaulure(res){},
timeout: timeout
});
}
adapterAuthRealmChallengeHandler.submitSuccess();
}
};
答案 0 :(得分:0)
在Idan Adar的帮助下,我得到了解决方案
我将以下函数放在adapterAuthRealmChallengeHandler.js
中adapterAuthRealmChallengeHandler.handleFailure = function(response) {
adapterAuthRealmChallengeHandler.startChallengeHandling();
};
调用上面的函数后,在adapterAuthRealmChallengeHandler.handleChallenge中,我检查了登录成功后设置的标志值。