title: How can I tell to EJS if user is logged in?
body: <p>I'm trying to check if a user is logged in to display specifc content. I have this:</p>
  
  <pre><code>app.get('/profile', isLoggedIn, (req, res) =&gt; {
      res.render('profile', {
          user: req.user, isLoggedIn: isLoggedIn()
      });
  });
  
  
  function isLoggedIn(req, res, next) {
  if (req.isAuthenticated()) {
      return next(null, true);
  }
  res.redirect('/');
  }
  </code></pre>
  
  <p>And as template:</p>
  
  <pre><code>&lt;%if (isLoggedIn) { %&gt;
   &lt;div&gt;Content 1&lt;/div&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>But I get this error: </p>
  
  <blockquote>
    <p>Cannot read property 'isAuthenticated' of undefined</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>