0
votes

I'm using MobileFirst Platform V8.0 and I need to update the active user attributes after a successful login. Is there any solution to update the active user without logout.

1

1 Answers

1
votes

You don't need to Logout to set the active user & You can set active user in adapter soon after user is authenticated by using API setActiveUser.

Details about setActiveUser and getActiveUser API's can be found here.

Following code is an example on how to do it in adapter for 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);
    }
}

For more information please go through this tutorial.