简体   繁体   中英

App page freezes for logged in user when performing meteor reset

When I have active Meteor login token and perform a DB drop with meteor reset , app page freezes badly on reload. It feels like the page keeps loading, though there is nothing on the page I can interact with. Browser console hangs as well. Tested on Chrome and Firefox, facing same behavior. But when I try to remove cache for the app domain (through browser settings, as dev tools are unconscious), everything becomes okay, I get redirected to a login page (as provided in my route config) and browser console has the following message: You've been logged out by the server. Please log in again You've been logged out by the server. Please log in again . This is my Iron Router global onBeforeAction hook:

Router.onBeforeAction(function () {

document.documentElement.className = 'gt-ie8 gt-ie9';

var currentUser = Meteor.user(),
    currentRoute = this.route.getName(),
    routeOptions = {},
    userRoles,
    userCompany, userTeam,
    allowedRoutes;

// prevent not logged in user from visiting the app
// console.log(this.next);
if (!currentUser) {
  this.redirect('login');
  // return;
} else {

  userRoles = currentUser.roles;

  userRoles = userRoles.length ? userRoles : ['member'];
  userCompany = currentUser.companyId || null;
  userTeam = currentUser.teamId || null;

  // get current user allowed routes (for highest role)
  allowedRoutes = _.filter(SW.roles, function (appRoute, index) {
    return userRoles.indexOf(index) > -1;
  });
  allowedRoutes = allowedRoutes && allowedRoutes.length ? allowedRoutes[0].routes : [];

  // if not all routes are allowed
  if (allowedRoutes.indexOf('*') === -1) {
    // restrict if route is not allowed
    if (!allowedRoutes.length || allowedRoutes.indexOf(currentRoute) === -1) {
      this.redirect('member.self');
    }
  }

}

this.next();

}, {
  except: ['enroll', 'login', 'logout']
});

I need to mention as well that this is very weird slippy issue that happens on production server far more often than when performing local testing.

The issue seems to be gone with the latest Meteor update (1.0.2.1). Though, it may be because of this issue with Fast Render (fixed in 2.1.0), which I'm using on my project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM