3

In the route below I'm checking if the user is logged in before rendering the content, but users sometimes gets logged out by the server and get the following message in the console:

Error logging in with token: Error: You've been logged out by the server. Please log in again. [403] undefined

When this happens, the check for userId() in the route still passes and the user gets a blank page and have to manually navigate to or reload to get to the login page. Is there a more reliable way of checking that the user is logged in and has a valid session going?

FlowRouter.route('/', {
    name: '_users.currentUser',
    action() {
      if (!Meteor.userId()) {
        FlowRouter.go('/login');
      }    
      mount(LayoutDefaultCtx, {
        content: () => (<UsersSingle _id={Meteor.userId()}/>),
      });
    }
});
oskare
  • 1,061
  • 13
  • 24

0 Answers0