2013-09-21 74 views
0

我在IBM Worklight 6.0中實現了Custom Authenticator和Login Module。認證機制工作正常。如何在Worklight中的用戶標識對象中設置和檢索自定義屬性?

我已經設置自定義的角色一樣,電子郵件等用戶標識對象的屬性..

在登錄模塊,

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

現在我無法檢索使用下面的API調用的屬性值。 WL.Client.getUserInfo(「CustomRealm」,「mail」);

回答

1

首先,您需要獲取領域的「屬性」選項。然後從該組屬性中獲取您的「郵件」屬性 。類似這樣的:

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