问题
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.
回答1:
Using fast-render
might be a solution. Just run
mrt add fast-render
Check this great article on this topic.
来源:https://stackoverflow.com/questions/23139627/meteor-js-check-logged-in-status-before-render