Last active
August 29, 2015 14:05
-
-
Save Azeirah/f9e6ae589b7fbb7797cc to your computer and use it in GitHub Desktop.
OnCreateUser doesn't get called
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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