문제

I've tried to implement a very simple, form based authentication with a Worklight app. However when I activate the login function, it stops with a 404 error, saying /apps/services/j_security_check can not be found. Oddly enough, when I run the form based authentication sample from IBM's developerWorks site, it works just fine. I can't figure out what the difference is, all the functions that have to do with authentication are exactly the same, yet with my own app I get this error message. Here's the relevant part from the source:

   var sampleAppRealmChallengeHandler = WL.Client.createChallengeHandler("SampleAppRealm");

sampleAppRealmChallengeHandler.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;
};

sampleAppRealmChallengeHandler.handleChallenge = function(response) {
    $.mobile.changePage($('#Login'));
    $('#passwordInputField').val('');
};

sampleAppRealmChallengeHandler.submitLoginFormCallback = function(response) {
    var isLoginFormResponse = sampleAppRealmChallengeHandler.isCustomResponse(response);
    if (isLoginFormResponse){
        sampleAppRealmChallengeHandler.handleChallenge(response);
    } else {
        $.mobile.changePage($('#page0'));
        sampleAppRealmChallengeHandler.submitSuccess();
    }
};

function proceedWithLogin() {

    console.log("proceedWithLogin");

    var reqURL = '/j_security_check';
    var options = {};
    options.parameters = {
        j_username : $('#loginEmail').val(),
        j_password : $('#loginPassword').val()
    };
    options.headers = {};
    sampleAppRealmChallengeHandler.submitLoginForm(reqURL, options, sampleAppRealmChallengeHandler.submitLoginFormCallback);
}

Any idea what could be causing this? Is there a hidden project setting that I've overlooked? Thanks!

도움이 되었습니까?

해결책 2

Looks like it was a problem with the Worklight project. I've set up a new project and copied everything over and now it works. No idea what the issue was, but it went away.

다른 팁

Could it be that you try to send your credentials before the response with the form has arrived? That would explain receiving a 404 j_security_check not found.

I think you haven't deployed the Adapter. Can you try testing after deploying the DummyAdapter by rightcliking on it->Run As -> Deploy Adapter.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top