 
       # redirect user to where he came from
       if loginRedirect and loginRedirect != 'logout'
-        console.log "Redirecting"
         Session.set loginRedirectKey, null
         @redirect loginRedirect
         pause()
 
-  , { except: ['login', 'logout', 'signup', 'game', 'highscores'] }
+  isLoggedOut: (pause) ->
+    if Meteor.userId()?
+      FlashMessages.sendWarning 'Du er allerede logget ind'
+      @redirect 'lobby'
+      pause()
+
+filters = Router._filters
+
+
+# client
+
+if Meteor.isClient
+
+  # before hooks
+
+  Router.onBeforeAction 'loading'
+  Router.onBeforeAction filters.isLoggedIn, only: [ 'logout', 'lobby', 'quiz' ]
+  Router.onBeforeAction filters.isLoggedOut, only: [ 'login', 'signup' ]
+
+
+  # routes
 
   Router.map ->
     # lobby

          @render 'notFound'
          pause()

        if not this.data()?#or game.state is 'inprogress'
          @render 'notFound'
          pause()

        # gameId = @params._id
        # game = null
        # Deps.nonreactive ->
        #   game = Games.findOne gameId
        #   console.log game
        # if not game? #or game.state is 'inprogress'
        #   @render 'notFound'
        #   pause()

      waitOn: ->
        Meteor.subscribe 'games'

    @route 'highscores'

    #game types
    @route 'single'
    @route 'duel'

    # DEBUG route
    @route 'quizzes', path: '/quizzes/'

    # quiz
    @route 'quiz',
