是否有特定的范围我可以使用WL.Server.SetActiveUser?

时间:2013-03-13 16:48:42

标签: authentication ibm-mobilefirst

我正在尝试在Worklight中创建基于适配器的身份验证。我已将我的Realm,安全测试和登录模块添加到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,
}
});

1 个答案:

答案 0 :(得分:0)

查看API documentation for WL.Server.setActiveUser,它应该是这样的:

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

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