Created
December 23, 2016 08:47
-
-
Save MrPrashantT/779b9a7910eda48a4ca3eb20efb1c8c8 to your computer and use it in GitHub Desktop.
Store Facebook graph profile picture URL in User Metadata
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
function (user, context, callback) { | |
if(context.connection !== 'facebook'){ | |
callback(null, user, context); | |
} | |
if(!user.user_metadata.fb_profile_pic){ | |
user.user_metadata = user.user_metadata || {}; | |
var fb_identity = _.where(user.identities,{provider: "facebook"}); | |
user.user_metadata.fb_profile_pic = 'http://graph.facebook.com/' + fb_identity[0].user_id + '/picture'; | |
auth0.users.updateUserMetadata(user.user_id, user.user_metadata) | |
.then(function(){ | |
callback(null, user, context); | |
}) | |
.catch(function(err){ | |
callback(err); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment