I want iron-router to choose the template based on a current time. For security reasons i can't trust the client time. So i wrote Meteor method what can return the server time. But Meteor.call can't return some value synchronously, so i need to provide some callback. It's not a problem, but i can't find any way to force router wait until callback get data. I tried to use route.render('template') in callback and it's work, but with delay (as expected). At first i see the template with route-data, and after moment it's replaced by restricted_template. So how i can choose the template base on data what returned from Meteor.call()? Or maybe exists some another way to get server time?
Sync the time, then in the callback run Router.go('someRoute');
.
Haven't looked at it much, but there are several packages for getting server time on the client. One such package https://github.com/mizzao/meteor-timesync
But be aware that if you're routes are all that are keeping your application secure, it isn't secure.