0
votes

I have implemented Custom Authenticator and Login Module in IBM Worklight 6.0. The authentication mechanism works fine.

I had set custom attributes in User identity object like roles, email, etc..

In Login module,

public UserIdentity createIdentity(String realm) {
Map<String, Object> customAttributes= new HashMap<String, Object>();
customAttributes.put("userName", username);
customAttributes.put("mail", customAttrValue); //customAttrValue - this has the email id
UserIdentity uiObj=new UserIdentity("CustomRealm", username, username, null, customAttributes, password);
return uiObj;
}

Now I am unable to retrieve the attribute values using the below api call. WL.Client.getUserInfo("CustomRealm", "mail");

1

1 Answers

1
votes

First you need to get the "attributes" option for the realm. Then get your "mail" attribute from that set of attributes. Something like this:

var attrs = WL.Client.getUserInfo("CustomRealm", "attributes");
var email = null;;
if (attrs) {
    email = attrs.mail;
}