title: NodeJS ExpressJS PassportJS - for Admin Pages Only
body: <p>Im using NodeJS, ExpressJS, Mongoose, passportJS &amp; connect-ensure-login. Authenticating users works perfectly.</p>
  
  <pre><code>....
  var passport = require('passport')
    , LocalStrategy = require('passport-local').Strategy
    , ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn;
  
  var app = express();
  ...
  app.use(passport.initialize());
  app.use(passport.session());    
  ...
  
  
  passport.use(new LocalStrategy({usernameField: 'email', passwordField: 'password'},
      function(email, password, done) {
    User.findOne({ 'email': email, 'password': password },
                 {'_id': 1, 'email':1}, function(err, user) {
  
      if (err) { return done(err); }
  
      if (!user) {
        return done(null, false, { message: 'Incorrect username.' });
      }
  
      return done(null, user);
    });
  }));
  
  passport.serializeUser(function(user, done) {
    done(null, user);
  });
  
  passport.deserializeUser(function(user, done) {  
    done(null, user);
  });
  
  app.post('/login', passport.authenticate('local',
      { successReturnToOrRedirect: '/home', failureRedirect: '/login' }));
  
  app.get('/logout', function(req, res){
    req.logout();
    res.redirect('/');
  });
  </code></pre>
  
  <p>Now, I want to add restrictions to some routes to be accessible only by admin. How can I do that? e.g. <code>/admin/*</code></p>
  
  <pre><code>var schema = new mongoose.Schema({
      name: String,
      email: String,
      password: String,
      isAdmin: { type: Boolean, default: false }
  });
  
  mongoose.model('User', schema);
  </code></pre>
  
  <p>Any hint? Thanks</p>