Javascript 删除自动发布后,如何读取Meter.user().services?
在我从我的项目中删除autopublish包之前,Javascript 删除自动发布后,如何读取Meter.user().services?,javascript,meteor,google-oauth,facebook-oauth,Javascript,Meteor,Google Oauth,Facebook Oauth,在我从我的项目中删除autopublish包之前,meteor remove autopublish, 我能够在oAuth服务中读取登录用户正在使用的内容,例如var facebookSignIn=Meteor.user().services.facebook或 var googleSignIn = Meteor.user().services.google; 之所以如此重要,是因为我会使用此googleSignIn或facebookSignIn信息来确定如何保存已登录用户的个人详细信息,例如
meteor remove autopublish
,
我能够在oAuth服务中读取登录用户正在使用的内容,例如var facebookSignIn=Meteor.user().services.facebook代码>或
var googleSignIn = Meteor.user().services.google;
之所以如此重要,是因为我会使用此googleSignIn
或facebookSignIn
信息来确定如何保存已登录用户的个人详细信息,例如:姓名、电子邮件和个人资料图片
在代码中:
var facebookSignIn = Meteor.user().services.facebook;
var googleSignIn = Meteor.user().services.google;
var ownderId = Meteor.user()._id;
if (facebookSignIn) {
console.log("Its a Facebook Account Sign in!");
var userName = Meteor.user().services.facebook.name;
var emailAdress = Meteor.user().services.facebook.email;
var facebookProfilePic = "http://graph.facebook.com/" + user.services.facebook.id + "/picture/?type=large";
}
else if (googleSignIn) {
console.log("Its a Google Account Sign in!");
var userName = Meteor.user().services.google.name;
var emailAdress = Meteor.user().services.google.email;
var googleProfilePic = Meteor.user().services.google.picture;
}
else {
console.log("Your not Signed in!");
}
既然我已经删除了自动发布软件包,我如何检索Meteor.user().services.facebook
和Meteor.user().services.google
在浏览器控制台(main.js:1140)中,将显示以下错误消息:
Uncaught TypeError: Cannot read property 'facebook' of undefined
main.js:1140中的代码是:
var facebookSignIn = Meteor.user().services.facebook;
您必须首先从服务器发布集合,以使该集合在客户端中可用(客户端必须订阅已发布的集合)
你在服务器上发布Meteor.users了吗<代码>Meteor.publish(“userPublication”,函数publishFunction(){return Meteor.users.find();})
@blueren谢谢我按照你的建议在服务器上发布了这篇文章,它成功了!很高兴知道。我把它作为你问题的答案,在服务器上做决定。服务
密钥包括不应发布的私有数据(散列密码、恢复令牌…)!
Meteor.publish("userPublication", function publishFunction(){
return Meteor.users.find(); })