samples/sample3/handlers/sessions.js
function adminsOnly(req, res, next) {
  if (req.session && _.contains(req.session.user.roles, 'admin')) {
    next();
  }
  else {
    res.status(401).send('Only administrators can access this resource');
  }
}
function adminsOnly(req, res, next) {
  if (req.session && _.contains(req.session.user.roles, 'admin')) {
    next();
  }
  else {
    res.status(401).send('Only administrators can access this resource');
  }
}
function adminsOnly ( req , res , next ) { if ( req . session && _ . contains ( req . session . user . roles , 'admin' ) ) { next ( ) ; } else { res . status ( 401 ) . send ( 'Only administrators can access this resource' ) ; } }
Prevents access to anyone who is not in the "admin" role.
Prevents access to anyone who is not in the admin role .