Search in sources :

Example 1 with UserUpdateProfileContext

use of org.keycloak.authentication.requiredactions.util.UserUpdateProfileContext in project keycloak by keycloak.

the class FreeMarkerLoginFormsProvider method createResponse.

@Override
public Response createResponse(UserModel.RequiredAction action) {
    String actionMessage;
    LoginFormsPages page;
    switch(action) {
        case CONFIGURE_TOTP:
            actionMessage = Messages.CONFIGURE_TOTP;
            page = LoginFormsPages.LOGIN_CONFIG_TOTP;
            break;
        case UPDATE_PROFILE:
            UpdateProfileContext userBasedContext = new UserUpdateProfileContext(realm, user);
            this.attributes.put(UPDATE_PROFILE_CONTEXT_ATTR, userBasedContext);
            actionMessage = Messages.UPDATE_PROFILE;
            if (isDynamicUserProfile()) {
                page = LoginFormsPages.UPDATE_USER_PROFILE;
            } else {
                page = LoginFormsPages.LOGIN_UPDATE_PROFILE;
            }
            break;
        case UPDATE_PASSWORD:
            boolean isRequestedByAdmin = user.getRequiredActionsStream().filter(Objects::nonNull).anyMatch(UPDATE_PASSWORD.toString()::contains);
            actionMessage = isRequestedByAdmin ? Messages.UPDATE_PASSWORD : Messages.RESET_PASSWORD;
            page = LoginFormsPages.LOGIN_UPDATE_PASSWORD;
            break;
        case VERIFY_EMAIL:
            actionMessage = Messages.VERIFY_EMAIL;
            page = LoginFormsPages.LOGIN_VERIFY_EMAIL;
            break;
        case VERIFY_PROFILE:
            UpdateProfileContext verifyProfile = new UserUpdateProfileContext(realm, user);
            this.attributes.put(UPDATE_PROFILE_CONTEXT_ATTR, verifyProfile);
            actionMessage = Messages.UPDATE_PROFILE;
            page = LoginFormsPages.UPDATE_USER_PROFILE;
            break;
        default:
            return Response.serverError().build();
    }
    if (messages == null) {
        setMessage(MessageType.WARNING, actionMessage);
    }
    return createResponse(page);
}
Also used : UserUpdateProfileContext(org.keycloak.authentication.requiredactions.util.UserUpdateProfileContext) UpdateProfileContext(org.keycloak.authentication.requiredactions.util.UpdateProfileContext) UserUpdateProfileContext(org.keycloak.authentication.requiredactions.util.UserUpdateProfileContext) LoginFormsPages(org.keycloak.forms.login.LoginFormsPages)

Aggregations

UpdateProfileContext (org.keycloak.authentication.requiredactions.util.UpdateProfileContext)1 UserUpdateProfileContext (org.keycloak.authentication.requiredactions.util.UserUpdateProfileContext)1 LoginFormsPages (org.keycloak.forms.login.LoginFormsPages)1