No 404 not found template rendered for slugs Meteo

2019-05-30 02:56发布

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.

0条回答
登录 后发表回答