No 404 not found template rendered for slugs Meteor

大憨熊 提交于 2019-12-08 06:11:13

问题


I setup a not found template and it only works for routes which don't have slugs in the URL. Furthermore, the iron-router-progress bar hangs at approx. 95% (same as for the forbidden template). I think it's because the client is waiting for subscription, but there is no returning data. Here is my code:

var admin = function(pause) {
    if (Meteor.user()) {
        var member = Member.findOne({slug: this.params.slug});
        if (member) {
            if (!Roles.userIsInRole(Meteor.userId(), [member.slug], ['admin'])) {
                this.render('forbidden');
                pause();
            }
        }
    }
}

this.route('teamMembers', {
        path: '/member/:slug/overview',
        onBeforeAction: admin,
        waitOn: function() { return [Meteor.subscribe('members', this.params.slug)]; },
        data: function() {
            return Members.findOne({slug: this.params.slug});
        }
});

For insance:

  • /member/john/overview123 -> notFound template rendered (✓)
  • /member123/john/overview -> notFound template rendered (✓)
  • /member/lisa/overview (lisa does not exist) -> no notFound template rendered (x)

Any help would be greatly appreciated.

来源:https://stackoverflow.com/questions/25794382/no-404-not-found-template-rendered-for-slugs-meteor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!