[solved] Accounts.onCreateUser not updating user fields

Here is my code that runs for Accounts.onCreateUser. This runs on the server (the file is in the server folder) :

Accounts.onCreateUser (function (options, user) {
	user.profile = options.profile ? options.profile : { 
		nameDisplay : user.username,
		entity : null,
		billingAddress: {},
		names : [],
		phones : [],
		address : [],
	var now = new Date();
	_.extend(user, { 
		tokenSM : null,
		customerId : null,
		employeeId : null,	
		salesrepId : null,
		createdAt: now 
  return user;

The terminal log shows the user object being created as expected.

I20150818-18:19:39.471(-7)? { createdAt: Tue Aug 18 2015 18:19:39 GMT-0700 (PDT),
I20150818-18:19:39.471(-7)? _id: ‘Ekn3tJXspNTtbY8py’,
I20150818-18:19:39.471(-7)? services: { password: { bcrypt: ‘$2a$10$DGrBi7IK0ibEDApx3XO/IO99rszpzIc4K9zmGaMZJQfqWF/vQXG0.’ } },
I20150818-18:19:39.471(-7)? username: ‘lucy’,
I20150818-18:19:39.471(-7)? emails: [ { address: ‘lucy@gmail.com’, verified: false } ],
I20150818-18:19:39.471(-7)? profile:
I20150818-18:19:39.471(-7)? { nameDisplay: ‘lucy’,
I20150818-18:19:39.471(-7)? entity: null,
I20150818-18:19:39.471(-7)? billingAddress: {},
I20150818-18:19:39.471(-7)? names: [],
I20150818-18:19:39.472(-7)? phones: [],
I20150818-18:19:39.472(-7)? address: [] },
I20150818-18:19:39.472(-7)? tokenSM: null,
I20150818-18:19:39.472(-7)? customerId: null,
I20150818-18:19:39.472(-7)? employeeId: null,
I20150818-18:19:39.472(-7)? salesrepId: null }

But only the profile fields are written to Mongo.

I know this is a real noob post but stuck is stuck and I’m stuck so a little insight will be gratefully accepted.


Arg. The issue is that the fields being added aren’t also being Published and Subscribed.

I am using Meteor Toys with the fabulous Mongol to watch the record contents. Mongol respects the Publish limits - I thought it didn’t. The tip off was when I attempted to add the field myself using Mongol and saw a console message:
"‘tokenSM’ is an unpublished field. This field’s value was not overwritten."