Pass metadata to Meteor.loginWith<ExternalService>()


#1

I am trying to figure out a way to pass metadata to the server when the user logs in.

Something like this:

Meteor.loginWith<ExternalService>([options], [callback], {metadata})

The metadata would consist of which app instances the client logged in from which is not available to the server and then could be stored along with some attempt properties to a LoginEvents collection:

Accounts.onLogin( function(attempt) {
   var event = _(attempt).pick([
       'type',
       'allowed',
       'metadata'
  ]);
  LoginEvents.insert(event)
});

Right now I have a hacky solution where I wait till after the user has logged in and search the most recent LoginEvents for that user and update it with the appId. It works but is buggy as race conditions are present.

I have gone through the Account source code and there is no way of passing the metadata unless I fork the package. Just want to see if anyone else has encountered a similar problem and how they have resolved it. Thanks