Redirecting not logged-in users with iron-router… Again

前端 未结 5 1922
梦毁少年i
梦毁少年i 2020-12-13 15:05

I am fighting with the common need for redirecting a user to a login page if he is not logged-in (Meteor v0.8.0 on Windows 7).

There are several similar questions on

5条回答
  •  情深已故
    2020-12-13 15:16

    It looks like this has something to do with waiting on subscriptions in waitOn.

    The following solves the layout rendering issues for me:

    Router.onBeforeAction(function() {
        if (!Meteor.user() && this.ready())
            return this.redirect('/login');
    }, {except: ['login']}); 
    

提交回复
热议问题