meteoraccounts

Merging multiple user accounts with Meteor


There is a good article on merging multiple user accounts with Meteor: http://www.meteorpedia.com/read/Merging_OAuth_accounts

I have an already logged in user. I want to the currently logged in user to login to Facebook and Linkedin and merge all the service objects. For this, I have created an Account.onCreateUser() function

Within the onCreateUser() function, I require to retrieve the following information:

  1. current UserId: I tried this.userId, it is not working
  2. current SessionId: in client, Meteor.data_connection._lastSessionId. Not sure how to get this in the server.

Any help is very useful.


Solution

  • The best way to merge multiple accounts is writing custom code in Accounts.onCreateUser. Within this method, retrieving session Id does not work. Migration of user data based on session Id should happen after accounts are migrated. Also, for this.userId to work within Accounts.onCreateUser, do not create new users in Meteor.startup.