5

First off lets just start with the fact that I am a complete noob with Meteor. Now that that is out of the way let the problem begin...

I have two pages, a splash page at '/' and a home page at '/home'. I am using iron-router for the routing. Now If I am not logged in and on the splash page and login I have it redirecting to the home page this works. Now if I close my browser and reopen and goto the '/' it loads for a few seconds then realizes that I am actually still logged in and then redirects me to '/home'.

My question is how to I get rid of this initial showing on the '/' when I am already logged in? I only want to show that page to people not signed in. Here is the code that I have in my router:

    Router.configure({layoutTemplate: 'mainLayout'});

Router.map(function() {
  this.route('splash', {path: '/'});
  this.route('home');
});

var mustBeSignedIn = function(pause) {
  if (!(Meteor.user() || Meteor.loggingIn())) {
    Router.go('splash');
    pause();
  }
};

var goToDashboard = function(pause) {
  if (Meteor.user()) {
    Router.go('home');
    pause();
  }
};

Router.onBeforeAction(mustBeSignedIn, {except: ['splash']});
Router.onBeforeAction(goToDashboard, {only: ['splash']});

Hope this helps.

BobFranz
  • 250
  • 2
  • 15
  • remember to add this.next() after upgrade meteor > 1.0 more here http://stackoverflow.com/questions/26629835/meteor-v-1-0-and-ironrouter – Bartek S Apr 10 '15 at 09:09

1 Answers1

3

Using fast-render might be a solution. Just run

mrt add fast-render

Check this great article on this topic.

Hubert OG
  • 19,314
  • 7
  • 45
  • 73
  • This is perfect. Installed, quick reboot of the server and all is as it should be! Thank you so much. – BobFranz Apr 17 '14 at 21:58