 # filters
 # ########
 mustBeAdmin = ->
-  unless Meteor.loggingIn() # don't check for admin user until ready
-    unless Houston._user_is_admin Meteor.userId()
-      @stop()
-      Houston._go 'login'
+  if @ready() and not Houston._user_is_admin Meteor.userId()
+    @stop()
+    Houston._go 'login'
 
 # If the host app doesn't have a router, their html may show up
 hide_non_admin_stuff = ->


Router.onBeforeAction mustBeAdmin,
  only: (Houston._houstonize_route(name) for name in ['home', 'collection', 'document', 'change_password'])
Router.onAfterAction hide_non_admin_stuff,
  only: (Houston._houstonize_route(name) for name in ['home', 'collection', 'document', 'login', 'custom_template'])
Router.onBeforeAction remove_host_css,
  only: (Houston._houstonize_route(name) for name in ['home', 'collection', 'document', 'login'])

Houston._subscribe = (name) -> Meteor.subscribe Houston._houstonize name

Houston._subscribe 'collections'

setup_collection = (collection_name, document_id) ->
  Houston._page_length = 20
