0
我正在使用MobileFirst Platform V8.0,並且我需要在成功登錄後更新活動用戶屬性。有沒有解決方案可以在不註銷的情況下更新活動用戶。IBM MobileFirst V8.0:更新活動用戶
我正在使用MobileFirst Platform V8.0,並且我需要在成功登錄後更新活動用戶屬性。有沒有解決方案可以在不註銷的情況下更新活動用戶。IBM MobileFirst V8.0:更新活動用戶
您不需要註銷以設置活動用戶&您可以在用戶通過使用API setActiveUser
進行身份驗證後立即在適配器中設置活動用戶。
關於setActiveUser
和getActiveUser
的詳細信息可以找到API的here。
以下代碼是關於如何在適用於Mobilefirst 8.0註冊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。