2015-09-07 31 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瞭解更多詳情。

我希望它可以幫助:-)

相關問題