title: Meteor.users collection is undefined on server
body: <p>What's wrong with this code? It's inside of a "server" folder. Line 11 here, is called out in the error log.</p>
  
  <pre><code>import { Accounts } from 'meteor/accounts-base';
  import generatePincode from '../../../utils/generate-pincode';
  import Meteor from 'meteor/meteor';
  
  Accounts.onCreateUser((options, user) =&gt; {
    const customizedUser = Object.assign({
      'pincode': generatePincode(4),
    }, user);
  
    // check that the pincode doesn't already exist
    const existingUser = Meteor.users.findOne({
      'pincode': customizedUser.pincode,
    });
    if (existingUser) {
      throw new Meteor.Error(500,
        'Duplicate pincode generated, please try again.');
    }
  
    // We still want the default hook's 'profile' behavior.
    if (options.profile) {
      customizedUser.profile = options.profile;
    }
    return customizedUser;
  });
  </code></pre>
  
  <p>The terminal (server) logs:</p>
  
  <blockquote>
    <p>Exception while invoking method 'createUser' TypeError: Cannot read property 'findOne' of undefined</p>
  </blockquote>