管理员登录后如何访问网站的其他页面

How can I reach other pages of website when admin logs in

admin 登录时如何访问其他页面。单击其他页面时始终显示仪表板页面link。你能检查一下我的代码吗?

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');
});

注意:当我单击用户和订单时 link 它会显示仪表板。

那是因为它被 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');
    }
  }
});

因此,如果用户是管理员,它会通过 onBeforeAction 并获取下一个有效路由