def update(user_id, username, email, active, profile_picture, roles, password=None):
    """
    Updates an existing user

    :param user_id:
    :param username:
    :param email:
    :param active:
    :param profile_picture:
    :param roles:
    :param password:
    :return:
    """
    strict_role_enforcement = current_app.config.get("LEMUR_STRICT_ROLE_ENFORCEMENT", False)
    if strict_role_enforcement and not any(role.name in STRICT_ENFORCEMENT_DEFAULT_ROLES for role in roles):
        return dict(message="Default role required, user needs least one of the following roles assigned: admin, "
                            "operator, read-only"), 400

    user = get(user_id)
    user.username = username
    user.email = email
    user.active = active
    user.profile_picture = profile_picture
    if password:
        user.password = password
    update_roles(user, roles)

    log_service.audit_log("update_user", username, f"Updating user with id {user_id}")
    return database.update(user)

    Updates an existing user

    :param user_id:
    :param username:
    :param email:
    :param active:
    :param profile_picture:
    :param roles:
    :param password:
    :return:
    
lemur/users/service.py