onCreateUser - Not Saving the User


I am using ian:accounts-ui-bootstrap-3 and accounts-password and for whatever reason I can’t get my user’s email and password to save.

So here is the code:

Accounts.onCreateUser(function(options, user) {
  options.roles = ['user'];
  user = {
    profile: options.profile,
    roles: options.roles
  return user;

The user is saved with the profile and roles correctly assigned; however, my email and password are gone…In addition, when I try to login again it says that the user cannot be found on the database. Any help is greatly appreciated.


I believe you need to add both the email and password to the object you return. Check the function parameters to see if you can find this information and put it in the object you’re returning.


in other words, instead of

user = {
profile: options.profile,
roles: options.roles


user.profile = options.profile;
user.roles = options.roles;

edit: you are inadvertently overriding the default behavior of the ‘user’ parameter by assigning it to another object. Just add the additional information to the already existing object.


Hi, try this.

user = _.extend(user,{profile : options.profile, roles : option.roles});