title: User Permission - Display edit in view (express, handlebars)
body: <p>At the moment I have user profiles that are rendered using Handlbars as such:</p>
  
  <pre><code>exports.profile = function(req, res) {
    User.findOne({username: req.params.username}).exec(function(err, user){
      res.render('profile/view', {
        user: req.user,
        name: user.name,
        username: user.username
      });
    });
  };
  </code></pre>
  
  <p>On the rendered template at <code>profile/view</code> I would like to display an edit button <strong>if</strong> the user can edit the profile being viewed. </p>
  
  <pre><code>&lt;a href="/edit/usernamehere"&gt;Edit your profile here&lt;/a&gt;
  </code></pre>
  
  <p>Additional information:</p>
  
  <ul>
  <li>Every user us currently authenticated with passport-local strategy</li>
  <li>Currently have some basic middleware on the route</li>
  </ul>
  
  <p><strong>Middleware</strong></p>
  
  <pre><code>app.get('/:username', isAuth, user.profile);
  
    function isAuth(req, res, next) {
      if (req.isAuthenticated()) {
        return next();
      }
      req.flash('alert', 'First you need to log in');
      res.redirect('/login');
    }
  </code></pre>
  
  <p>I've looked into middleware for express such as <a href="https://www.npmjs.com/package/connect-roles" rel="nofollow">connect-roles</a> and I don't think its what I need?</p>
  
  <p>What I'm thinking is that I should pass a boolean within the local variables of the <code>res.render()</code> method which then allow me to use handlebars to display the button or not.</p>
  
  <pre><code>{{#if profileOwner }}&lt;a href="#"&gt;...
  </code></pre>
  
  <p>Any ideas?</p>