Check login in FlowRouter in Meteor
<p>I am using FlowRouter in Meteor.</p>

<p>On some pages, I want to check if the user is logged in, so I have made a triggerEnter function</p>

<pre><code>const isAuthenticatedRedirect = ( context, redirect, stop ) =&gt; {
  if ( ! Meteor.loggingIn() &amp;&amp; ! Meteor.userId() ) {
    FlowRouter.go( 'login' );
  }
};

const isAuthenticatedRoutes = FlowRouter.group( {
  name: 'isAuthenticated',
  triggersEnter: [ isAuthenticatedRedirect ]
} );
</code></pre>

<p>The problem is that it redirects the user to <code>/login</code> rather than just showing the login template.</p>

<p>I could make an if statement on all the pages, and then show the login instead of the real page if the user is not logged in, but I guess it would be way smarter to do it directly in the router.</p>