I’m trying to do a check to see if the user has an object on it, if it doesn’t I render a different template.
Just like checking if the user is logged in with Meteor.userId(). Except my problem is that it seems Meteor.user() only returns certain fields. I can’t get it to return the object on the user.
Question, do I have to create a pub/sub just for currentUser or can I change what is returned by Meteor.user().
Secondly, as I’m trying to do this in an Router.onBeforeAction, can I/do I have to put a waitOn in the onBeforeAction somehow? I just want this info for the routing.
lastly, is there a way to do {name: ‘whatever’} inside the onBeforeAction? Instead of the ugly .render … controller etc?
Maybe I’m going about this the wrong way but its proving tough to get this right.
My code looks like so…
Router.route('/', {name: 'home'});
Router.onBeforeAction(function () {
if (!Meteor.userId()) {
this.render('login');
} else if (!Meteor.user().customObject) {
this.render('add', {
controller: 'addController'
});
} else {
this.next();
}
});