Meteor iron:路由器this.render()正在BeforeAction钩子中阻塞

Meteor iron:router this.render() is blocking in onBeforeAction-hook

本文关键字:BeforeAction 正在 iron 路由器 this render Meteor      更新时间:2024-04-06

所以我已经搜索了几个小时的解决方案,但似乎自己都想不出来。我有iron:router onBeforeAction挂钩设置来检查不同的权限,例如,如果用户登录了。然而,一旦权限检查失败,并且调用了.render(..),我就会一直停留在该模板上,直到我重新加载页面-单击另一个路由的链接是不够的。

var onBeforeActions = {
    loginRequired: function() {
        if(Meteor.loggingIn() || !this.ready()) {
            return this.render('loading');
        } else if(!Meteor.user()) {
            return this.render('accessDenied');
        }
        return this.next();
    },
...
Router.onBeforeAction(onBeforeActions.loginRequired, {
    only: ['postSubmit', 'postSubmitHandhistory', 'postEdit', 'postPage', 'groupJoin', 'groupPage', 'groupEdit'],
});

因此,例如,我在一个受限页面上,再次单击"注销"answers"登录"。然后我一直坚持加载模板,直到我点击F5。我可以看到路由发生了变化,因为我可以看到数据上下文发生了变化但没有重新加载yield布局。我还检查了onBeforeAction是否重新运行,事实上,它甚至到达了

this.next();

但它并没有重新招标。。有什么想法吗?

好的,我终于找到了问题的解决方案。路由器似乎没有什么问题,但我的页面转换中出现了一个错误,不知何故,它阻止了旧布局的删除。