2015-09-07 33 views
1

在我的路由文件中,我有以下内容。如何获得注销用户流星的电子邮件地址?

Router.route('/user/:createdBy', { 
     name: 'user', 
     /*onBeforeAction: function() { 
     AccountsEntry.signInRequired(this); 
     },*/ 
     fastRender: true, 
     data: function() { 
      paramId = this.params.createdBy; 
      // Still have to find a way how to get data 
      // Function below is only for signed in users 
      return Meteor.users.findOne(paramId); 
     } 
}); 

在我的用户模板我想显示的电子邮件。我有这样的{{emails.[0].address}}{{users.emails.[0].address}}但电子邮件不显示。它仅在用户登录时显示。但是,我将用户标识作为我的参数。 (这是为了测试目的的家伙!)。

+1

什么用户发布到未登录的用户?您可以创建一个服务器发布,将paramId作为参数并返回该用户(作为游标),然后在您的路由的“waitOn”部分中订阅该用户。 –

回答

0

如果你想使用注销用户的信息,你可以试试这个:

// in your router.js 

// callback would be called when login is successful 
Meteor.onLogin(function(){ 
    Session.set('login user', Meteor.user()); 
}) 

// in your template, or other functions 
// the Session would be update only if a user login successfully 
var userId = Session.get('login user')._id; 

点击here了解更多详情。

我希望它可以帮助:-)

相关问题