【发布时间】:2017-06-20 19:29:16
【问题描述】:
我正在为我的应用程序编写许可证验证部分,并且当且仅当他们的许可证已过期时,我才希望将用户重定向到续订页面。
我正在使用 FlowRouter 和 Blaze。
我所有经过身份验证的路由都在一个组中:
let authenticated = FlowRouter.group({
triggersEnter: [checkAuthenticated, checkSubscription]
});
然后我检查订阅是否有效,如下所示:
const checkSubscription = function(context){
let path = FlowRouter.current().path;
if (!Meteor.userId()){
return;
}
const sub = new Subscription();
if (sub.isInvalid() && path !=="/manage-practice/subscription"){
FlowRouter.go("/manage-practice/subscription");
}
};
我的课程订阅使用了一个集合,我只能在用户登录后加载。我的问题是路由器通常在加载此数据之前触发此重定向。
是否有解决此问题的最佳实践方法?
【问题讨论】:
-
您在使用 AccountsTemplates 吗?我整理了一个带有 AccountsTemplates 和 alanning:roles 的解决方案,它在执行任何路由之前等待角色。这很丑陋,但它有效。
标签: meteor meteor-blaze flow-router