Accounts.onLogin redirect base on role possible?

Hi, im trying to redirect admin login to dashboard, using flowrouter
the code works fine upon login, but when you try to open another tab in the browser, it performs another login and i got redirect to the dashboard again(basically you can’t navigate using url, each url input into the browser will cause another login and redirect you back to the dashboard), the code im using is below

if (Meteor.isClient) {
  Accounts.onLogin(function() {
    if (Roles.userIsInRole(Meteor.userId(), ['admin'])) {
      FlowRouter.go('adminHome');
    }
  });
}

im using
Meteor 1.4.4.1
alanning:roles 1.2.16
kadira:flow-router 2.12.1
kadira:blaze-layout 2.3.0

1 Like