title: Admin user role in nodejs
body: <p>My web app needs 2 user roles (user and admin).I am using passport local authentication for this.</p>
  
  <p>For now by adding the code below I have 2 roles but the admin's one has access to user routes too. I have to go by hand to /admin route in order to user its features.</p>
  
  <pre><code>function isLoggedIn(req, res, next) {
  if (req.isAuthenticated())
      return next();
  res.redirect('/login');
  }
  
  function isAdmin(req, res, next) {
  if (req.isAuthenticated()) {
      if (req.user.local.role == "admin") {
          return next();
      }
  }
  res.redirect('/login');
  }
  </code></pre>
  
  <p><strong>Now my question is how can I change isAdmin function so that when I log in as administrator I go instantly to the /admin route ?</strong></p>