我可以使用以下内容获取_id
和username
等常规字段:
users: function () {
return Meteor.users.find({}, {fields:{_id:1,username:1}});
}
但如何获取来自Facebook / Google / Twitter的profile.name
?
答案 0 :(得分:1)
使用http://docs.meteor.com/#/full/accounts_oncreateuser挂钩来编写profile.name
。
Accounts.onCreateUser(function(options, user) {
// We still want the default hook's 'profile' behavior.
if (options.profile) {
user.profile = options.profile;
user.profile.memberSince = new Date();
// Copy data from Facebook to user object
user.profile.facebookId = user.services.facebook.id;
user.profile.firstName = user.services.facebook.first_name;
user.profile.email = user.services.facebook.email;
user.profile.link = user.services.facebook.link;
}
return user;
});
Getting Facebook Avatar in Meteor when Autopublish is removed