Flow Router and a server check before the template is loaded

Dear Meteorusers,

This is my first post on this forum, sorry if I do something wrong.

I want to build a protected room page. Only people that are signed in in that room in the Rooms collection my view the page. I build a check on the server called validRoom and that checks if the userId is in the array of the room he / she tries to enter.

The problem is that Flow Router doesn’t want async code in the triggerEnter.

I want it in routing because this will also check if someone tries to join the room directly when he / she is not allowed.

Am I missing something? does the check needs to be somewhere else? Currently I have the check on Template.room.onCreated(…) but I really dislike that, because the user has to render the page because he / she is told to f*ck off.

Hopefully you guys can help me,


I was in the same situation as you, trying to make some async calls at the router level. I also ended up keeping them in the template level (as is suggested by @arunoda in the flow router docs and tuts). You could definitely put a helper in your {{else}} block that would log the ip address, etc. of the users who aren’t authenticated.