pipe理员login时如何才能访问其他网页

如何在pipe理员login时访问其他页面。单击其他链接时始终显示仪表板页面。 你能检查我的代码吗?

Router.onBeforeAction(function() { if (!Meteor.user()) { this.render('login'); } else { this.render('dashboard'); } }); Router.route('users', function() { this.render('users'); }); Router.route('orders', function() { this.render('orders'); }); 

注:当我点击用户和订单的链接,它显示我的仪表板。

那是因为它被onBeforeAction拦截,你应该这样做:

编辑:使用https://github.com/alanning/meteor-roles你需要:

 Router.onBeforeAction(function() { if (!Roles.userIsInRole(Meteor.user(), ['admin'])) { if (!Meteor.user()) { this.render('login'); } else { this.render('dashboard'); } } }); 

所以如果用户是一个pipe理员,它会传递onBeforeAction并获得下一个有效的路由