In Meteor, I'd like to add a referrer
field to new user signups. I can do this for users that register with a password, by passing in extra options to be used with Accounts.onCreateUser(function (options, user)
.
But this doesn't seem to work with social login. Any ideas how I can get this working?
I think I had a similar issue, and ended doing something like
So:
//server
Accounts.onCreateUser(function(options, user) {
if (user.services.facebook)
user.askReferer = true;
retur user;
});
//client
var userId;
Tracker.autorun(function() {
var user = Meteor.user();
if (!user || user.id === userId || !user.askReferer) {return;}
userId = user.id;
var referer = ...;
Users.update({_id: user.id}, {$set: {referer: referer}}, {$unset: {askReferer: 1}});
});
Would love if someone comes up with a better solution!