Accounts.createUser does not create profile field in Meteor 2.5

What has happened! I cannot create profile field while creating user like before. See my example.

const id = Accounts.createUser({

    email: 'ee@mail.com',

    password: 'pw',

    profile: {

        name: {

            first: 'Myfirst',

            last: 'Lastname',

        }

    }

})


console.log('user', Meteor.users.findOne(id));


user {
  _id: 'MxtHk3N5NHzz9PPDY',
  createdAt: 2021-10-27T16:22:53.252Z,
  services: {
    password: {
      bcrypt: '$2b$10$/8rCxrqvXRq7B.yNq5dFc2BMX.UC'
    }
  },
  emails: [ { address: 'ee@mail.com', verified: false } ]
}

Edit: i investicated this more. I don’t understand why Accounts.onCreateUser is not called. When i remove this , everything works.


Accounts.onCreateUser((options, user) => {

  check(options, Object);

  check(user, Object);

  console.log('options', options);

  console.log('user', user);

  if (!Meteor.isDevelopment) {

    throw new Meteor.Error(500, 'Users can be created in DEV mode only ')

  }

  return user;

});

From documentation

By default the profile option is added directly to the new user document. To override this behavior, use Accounts.onCreateUser .

Hi,

Well i have done about 40 different meteor projects. Now i updated my project from 2.3.5 to 2.5.

I dont really understand why oncreateuser removes the profile field and does not get called at all but still somehow removes the profile field.

Hi, we didn’t change this behavior, it was always working like this.

If you found any difference in behavior please open an issue with a reproduction but I don’t think that is the case here.

Thanks.

Thanks! Yes this is bery strange, and happens only in this project :smiley: i need to investigate more…

I made a similar mistake in the past when attaching a Schema without profile structure. Then I solved adding a blackbox profile field in my Schema.

Hi, thanks. I have not schema attached at all at this project. Weird…