0

我正在尝试在 Worklight 中创建基于适配器的身份验证。我已将我的领域、安全测试和登录模块添加到 authenticationConfig 文件中。我试图跟随 IBM 提供的模块。我已经复制了 WL.Server.setActiveUser 方法的确切语法甚至硬编码值。但我继续收到错误消息。我可以在一定范围内使用此方法吗?有谁看到或知道我的错误在哪里?

我继续收到以下错误:

LOG: Request [login] 
LOG: Request [/apps/services/api/GPC2/android/query] 
LOG: response [/apps/services/api/GPC2/android/query] success: /*-secure-
{"responseID":"1","isSuccessful":true,"resultSet REMOVED LINE THAT CONTAINED DB RESULTS FOR     SECURITY
[/apps/services/api/GPC2/android/query] exception. 
SCRIPT5007: Unable to get value of the property 'setActiveUser': object is null or undefined 

var lname= responseData.invocationResult.resultSet[0].somelastname;
var gpcid = responseData.invocationResult.resultSet[0].someid;
var fname = responseData.invocationResult.resultSet[0].somefname;
WL.Logger.debug("Login :: SUCCESS" + lname + " " + gpcid + " " + fname);  //this line does write the values to the log

//WL.Client.login("NotificationsRealm");
WL.Server.setActiveUser ("NotificationsRealm", {
userId: gpcid,
displayName: fname,
attributes: {
firstName: fname,
lastName : lname,
isUserAuthenticated: 1,
}
});
4

1 回答 1

0

查看 WL.Server.setActiveUser的API 文档,应该是这样的:

WL.Server.setActiveUser ("ACMERealm", {
    userId: "38017840288",
    displayName: "John Doe",
    attributes: {
        "firstName": "John",
        "lastName": "Doe",
        "lastLogin": "2010-07-13 19:25:08.0 GMT",
    }
})

看起来您缺少属性的双引号?

于 2013-03-14T17:14:33.257 回答