Meteor.user()不包含电子邮件字段

Meteor.user() doesn’t contain emails field

本文关键字:包含 电子邮件 字段 user Meteor      更新时间:2023-09-26

我正在使用帐户谷歌,我不知道它为什么不向客户端发布电子邮件。

来自Meteor.user((的文档:

默认情况下,服务器发布用户名、电子邮件和配置文件(可由用户写入(。

我只得到

Object { _id: "vK5ddWtypCewCwbSL", profile: Object }

在我的客户端上运行Meteor.user((后,但我想使用Meteor.user.emails,我错过了什么?

如果删除了自动发布模块,则需要手动发布用户集合

如果您使用的是服务器端发布方法,那么在从服务器发布该字段之前,您将不会获得电子邮件字段。

在服务器端使用以下代码。

Meteor.publish("user",function(){
  return Meteor.users.find(this.userId,{
    fields:{
        "services.google.accessToken":0,
        "services.google.expiresAt":0,
        "services.google.idToken":0,
        "services.resume":0
    }
  });
});

此方法将允许您访问客户端的电子邮件字段。