【问题标题】:How to get logged off users email address in meteor?如何在流星中注销用户的电子邮件地址?
【发布时间】:2015-12-03 12:35:38
【问题描述】:

在我的路由文件中,我有以下内容。

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}},但电子邮件没有显示。它仅在用户登录时显示。但是我将用户 ID 作为我的参数。 (这是为了测试目的!)。

【问题讨论】:

  • 您将哪些用户发布给未登录的用户?您可以创建一个以 paramId 作为参数并返回该用户(作为光标)的服务器发布,然后在您的路由的 waitOn 部分订阅它。

标签: email templates meteor iron-router


【解决方案1】:

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

// 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了解更多详情。

我希望它可以帮助:-)

【讨论】:

    猜你喜欢
    • 2015-06-19
    • 1970-01-01
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 2023-04-05
    • 2016-06-11
    相关资源
    最近更新 更多