Так что я только начинаю с железного маршрутизатора, и я строю систему входа. Он работает через крюк .onBeforeAction перед каждым маршрутом, проверяя, зарегистрирован ли пользователь. Однако есть несколько маршрутов, которые я хочу публиковать, поэтому я добавил параметр except, как в документах. Кроме проблемы это не работает :(может кто-нибудь, почему?железо-роутер кроме сбоев?
Router.route('/new', function() {
name: 'new',
this.render('newComp');
});
Router.route('/c/:_id', {
name: 'compPage',
data: function() { return Comps.findOne(this.params._id); }
});
Router.route('/c/:_id/embed', function() {
name: 'embed',
this.layout('empty'),
this.render('compEmbed', {
data: function() {
return Comps.findOne({_id: this.params._id});
}
});
});
function loginFunction(){
// all properties available in the route function
// are also available here such as this.params
if (!Meteor.user()) {
// if the user is not logged in, render the Login template
if (Meteor.loggingIn()) {
this.render(this.loadingTemplate);
} else {
this.layout('empty');
this.render('login');
}
} else {
// otherwise don't hold up the rest of hooks or our route/action function
this.next();
}
}
Router.onBeforeAction(loginFunction, {
except: ['embed'] // this aint working
});
Очень ясный ответ, овацию. – user1855596