samples/sample3/handlers/sessions.js
function mustBeLoggedIn(req, res, next) {
  if (req.session && req.session.user) {
    next();
  }
  else {
    res.status(401).send('You must be logged-in to access this resource');
  }
}
function mustBeLoggedIn(req, res, next) {
  if (req.session && req.session.user) {
    next();
  }
  else {
    res.status(401).send('You must be logged-in to access this resource');
  }
}
function mustBeLoggedIn ( req , res , next ) { if ( req . session && req . session . user ) { next ( ) ; } else { res . status ( 401 ) . send ( 'You must be logged-in to access this resource' ) ; } }
Prevents access to anonymous users.
Prevents access to anonymous users .