Meteor not setting username with Accounts.createUser [solved]



I am using Accounts.createUser on the server side and it is not adding the username when creating, nor is it adding it from creating an account from facebook or google.

Client side I have{
  'submit form': function(event) {
    var userName =;
    var emailVar =;
    var passwordVar =;'newUser', userName, emailVar, passwordVar, ()=>{
      Meteor.loginWithPassword(emailVar, passwordVar);

Server side I have:

Meteor.startup(() => {
  // code to run on server at startup
  Accounts.onCreateUser(function (options, user) {

      if ( {
        user.username =;
        user.emails = [{address:}];
      else if( {
        user.username =;
        user.emails = [{address:}];

      return user;


      username: name,
      email: email,
      password: password

I am using login with google, and login with facebook which is creating the account fine but it also not creating the username as it should with onCreateUser.

Also as a side note, what is the easiest way to get all user data, and also remove all users and start fresh.

Thank you,
Mike Acre


I figured out my issue was with my schema I had set up. It did not include a username, I simply forgot I had already set up a user Schema.