I am trying to authenticate my application users with a LDAP module with Worklight. This is working very well with this client code :
var ldapRealmChallengeHandler = WL.Client.createChallengeHandler("LDAPRealm");
function wlCommonInit(){
WL.Client.login("LDAPRealm");
}
ldapRealmChallengeHandler.isCustomResponse = function(response) {
if (!response || response.responseText === null) {
return false;
}
var indicatorIdx = response.responseText.search('j_security_check');
if (indicatorIdx >= 0){
return true;
}
return false;
};
ldapRealmChallengeHandler.handleChallenge = function(response){
};
ldapRealmChallengeHandler.submitLoginFormCallback = function(response) {
var isLoginFormResponse = ldapRealmChallengeHandler.isCustomResponse(response);
if (isLoginFormResponse){
ldapRealmChallengeHandler.handleChallenge(response);
}
else {
ldapRealmChallengeHandler.submitSuccess();
window.location.hash = "classes";
}
};
submitLoginForm = function(username, password){
var reqURL = '/j_security_check';
var options = {};
options.parameters = {
j_username : username,
j_password : password
};
options.headers = {};
ldapRealmChallengeHandler.submitLoginForm(reqURL, options, ldapRealmChallengeHandler.submitLoginFormCallback);
}
logout = function(){
WL.Client.logout('LDAPRealm',{});
changePage(loginPage);
}
When I log in the first time it works well. However, if I logout, and I try to login a second time, an error appears : "File not found: /apps/services/j_security_check".
I tried several things :
I took the code sample on the Worklight Getting Started website. They have the following code to logout : WL.Client.logout('LDAPRealm',{onSuccess: WL.Client.reloadApp}). If I delete the WL.Client.reloadApp part, the same problem than mine occurs : "/apps/services/j_security_check".
I put the WL.Client.login("LDAPRealm") in the submitForm before calling the server but it's not working.
Why this problem is happening ? Is reload the entire application the only way to solve the problem ? Because it's not really time efficient ...
Thanks a lot for your help.
WL.Client.isUserAuthenticated("LDAPRealm")
if it is authenticated after logging out also means your logout has some problem. Also you will receive error ` "File not found: /apps/services/j_security_check".` whenever you are submitting form without challenge – BluewingsWL.Client.isUserAuthenticated("LDAPRealm")
is true after the logout. However, when I logout, my application received a success event from the server so I don't know what I can do ... All the solutions I have found is to reload the app entirely but I would prefer an other solution ... – cmartetWL.Server.setActiveUser("LDAPRealm", null);
– BluewingsWL.Server is undefined
– cmartet