If new users subscribe, I take them to the initial route, so they can enter a name that is in /gs . I store the name inside the name property of the current user profile object. Now, if a user who has already entered a name and visits the /gs route, I want to redirect them to the root directory. In an iron router, I do this:
Router.route('/gs', { name: 'gs', onBeforeAction: function() { if ( Meteor.user().profile.name ) { this.redirect('/'); } else { this.render(); } } });
Although this works, it prints 2 errors to the console. One of them is "Unable to read property" profile of "undefined" and the absence of this.next() . Any way to fix these problems.
source share