Skip to content

Instantly share code, notes, and snippets.

@Azeirah
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Azeirah/f9e6ae589b7fbb7797cc to your computer and use it in GitHub Desktop.
Save Azeirah/f9e6ae589b7fbb7797cc to your computer and use it in GitHub Desktop.
OnCreateUser doesn't get called
if (Meteor.isServer) {
var _onCreateUser = Accounts.onCreateUser.bind(Accounts);
// Since onCreateUser overrides default behavior, and we don't want to restrict package users
// by removing the onCreateUser function, we override onCreateUser to modify the user document before the regular onCreateUser call.
Accounts.onCreateUser = function (func) {
console.log('oncreatinguser outer');
_onCreateUser(function (options, user) {
console.log('oncreateuser inner');
if (!user.profile) {
user.profile = options.profile || {};
}
if (!user.profile.friends) {
user.profile.friends = [];
}
return func(options, user);
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment