【发布时间】:2017-03-15 14:00:11
【问题描述】:
我使用的是 MobileFirst Platform V8.0,我需要在成功登录后更新活动用户属性。是否有任何解决方案可以在不注销的情况下更新活动用户。
【问题讨论】:
标签: ibm-mobilefirst mobilefirst-adapters
我使用的是 MobileFirst Platform V8.0,我需要在成功登录后更新活动用户属性。是否有任何解决方案可以在不注销的情况下更新活动用户。
【问题讨论】:
标签: ibm-mobilefirst mobilefirst-adapters
您无需注销即可设置活动用户,您可以在使用 API setActiveUser 对用户进行身份验证后立即在适配器中设置活动用户。
有关setActiveUser 和getActiveUser API 的详细信息可以在here 找到。
以下代码是关于如何在 Mobilefirst 8.0 Enrollment Sample 的适配器中执行此操作的示例。
public void authorize(Set<String> scope, Map<String, Object> credentials, HttpServletRequest request, AuthorizationResponse response) {
PersistentAttributes attributes = registrationContext.getRegisteredProtectedAttributes();
if (attributes.get("pinCode") != null){
// Is there a user currently active?
if (!userLogin.isLoggedIn()){
// If not, set one here.
authorizationContext.setActiveUser(userLogin.getRegisteredUser());
}
setState(SUCCESS_STATE);
response.addSuccess(scope, getExpiresAt(), this.getName());
} else {
setState(STATE_EXPIRED);
Map <String, Object> failure = new HashMap<String, Object>();
failure.put("failure", "User is not enrolled");
response.addFailure(getName(), failure);
}
}
欲了解更多信息,请通过this tutorial。
【讨论】: