Last active
August 29, 2015 14:05
-
-
Save guilhermedecampo/506a1ab7abbba36399c0 to your computer and use it in GitHub Desktop.
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
Accounts.onCreateUser(function(options, user) { | |
// We're enforcing at least an empty profile object to avoid needing to check | |
// for its existence later. | |
if (user.services && user.services.facebook) { | |
var | |
accessToken = user.services.facebook.accessToken, | |
result, | |
profile, | |
config | |
; | |
result = Meteor.http.get("https://graph.facebook.com/me", { | |
params: { | |
access_token: accessToken | |
} | |
}); | |
if (result.error) | |
throw result.error; | |
profile = result.data; | |
user.profile = profile; | |
} else { | |
user.profile = options.profile ? options.profile : {}; | |
} | |
return user; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment