我没有删除自动发布也没有删除不安全的软件包,但是当我运行Meteor.user()时它会显示服务。 Facebook对象但不是services.google对象(也不是services.password,但我不需要那个)。
谷歌和Facebook对象肯定都在数据库中,为什么它只显示一个?你会如何进行故障排除?当autupub开启时,我以为所有的领域都是顽皮的。
答案 0 :(得分:2)
首先,确保“.meteor / packages”文件中列出了“accounts-base”,“accounts-facebook”和“accounts-google”。一切都表明您没有将“accounts-google”软件包添加到该文件中。
发布“Meteor.users”的“accounts-base”软件包会覆盖默认的自动发布功能(https://github.com/meteor/meteor/blob/devel/packages/accounts-base/accounts_common.js#L82)。
要查看自动发布的字段,请参阅accounts_server.js上的源代码,从以下位置开始:https://github.com/meteor/meteor/blob/devel/packages/accounts-base/accounts_server.js#L683
您将看到以下内容(阅读评论):
// If autopublish is on, publish these user fields. Login service
// packages (eg accounts-google) add to these by calling
// Accounts.addAutopublishFields Notably, this isn't implemented with
// multiple publishes since DDP only merges only across top-level
// fields, not subfields (such as 'services.facebook.accessToken')
var autopublishFields = {
loggedInUser: ['profile', 'username', 'emails'],
otherUsers: ['profile', 'username']
};
这意味着“accounts.addAutopublishFields”方法将由“accounts-google”,“accounts-facebook”等软件包调用,以便为该出版物添加字段。
现在,例如,如果您查看“{3}}”,在“google.js”文件中,它具有以下内容:
Accounts.addAutopublishFields({
forLoggedInUser: _.map(
// publish access token since it can be used from the client (if
// transmitted over ssl or on
// localhost). https://developers.google.com/accounts/docs/OAuth2UserAgent
// refresh token probably shouldn't be sent down.
Google.whitelistedFields.concat(['accessToken', 'expiresAt']), // don't publish refresh token
function (subfield) { return 'services.google.' + subfield; }),
forOtherUsers: _.map(
// even with autopublish, no legitimate web app should be
// publishing all users' emails
_.without(Google.whitelistedFields, 'email', 'verified_email'),
function (subfield) { return 'services.google.' + subfield; })
});
这意味着如果您启用了“accounts-google”打包,它会将以下字段发布到“Meteor.users”:
登录后:'个人资料','用户名','电子邮件'和所有“service.google”字段,除了'accessToken','expiresAt'
注销时'个人资料','用户名'和所有“service.google”字段,“email”,“verified_email”除外
“accounts-facebook”套餐也是如此。