I want to check if a user is registered via Meteor.user () inside onBeforeAction on my routes. The problem is that after reloading the page, Meteor.user () returns undefined for a split second before it loads.
Here is my config route:
Router.map(function() { this.route('list', { path: '/list', template: 'list', onBeforeAction: function(){ console.log('onBeforeAction'); if(!Meteor.user()){ Router.go('/login'); } this.next(); } }); });
I have a lot of google and workarounds with "waitOn" and "return Meteor.user ();" doesn't seem to work in my case. Itβs also interesting ... locally it works fine, so I can reload the page and still remain in the list view, but the deployed application on the module acts as described above and redirects to the login page.
Any ideas? Thanks in advance.
source share