Reputation: 237
I am using adapter authentication in the sample app that I am working on. I needed the login page in the start up, so I have used the WL.Client.Login
in the js file liek this
function wlCommonInit(){
WL.Client.login("AuthRealm", {onSuccess: winFunction, onFailure: failureFunction});
}
it calls the challenger handler and below function is getting invoked
$("#AuthSubmitButton").bind('click', function () {
var username = $("#AuthUsername").val();
var password = $("#AuthPassword").val();
console.log("called");
var invocationData = {
adapter : "Auth",
procedure : "submitAuthentication",
parameters : [username,password ]
};
So it goes to the Adapter-impl.js file where I am getting the input like this..
var auth = WL.Server.createSQLStatement("select * FROM users WHERE Username = ? AND Password = ? ;");
function submitAuthentication(username,password){
return WL.Server.invokeSQLStatement({
preparedStatement :auth,
parameters : [username,password],
});
}
The problem is, it successfully shows the login page on start up and it goes to the adapter file too.. I dont know where can I create useridentity and WL.Server.setActiveUser("AdapterAuthRealm", userIdentity);
as WL.Server.invokeSQLStatement
not accepting onsuccess
parameter.
There is no examples available for the Sql adapter authentication for worklight. So I had no option but to ask a question. Please help me with this!
Upvotes: 0
Views: 495
Reputation: 3166
you don't need to just return sql invocation result. On the contrary, use it in your adapter to see whether authentication was successful. e.g.
var result = WL.Server.invokeSQLStatement(....);
if (result is not empty) {
WL.Server.setActiveUser("realm", userIdentity).
return {authStatus:"success"};
} else
return {authStatus:"failure"};
Upvotes: 1