code: function ensureLoggedIn(options) {
      var url = getRedirectTo( options, 'login' );
      var setReturnTo = (options.setReturnTo === undefined) ? true : options.setReturnTo;
      return function(req, res, next) {
          var auth = req.loggedIn || (req.isAuthenticated ? req.isAuthenticated() : false);
          if( !auth ) {
              if( setReturnTo && req.session ) {
                  req.session.returnTo = req.originalUrl || req.url;
              }
              return res.redirect( url );
          }
          next();
      };
  }
docs: AuthModule ensureLoggedIn
  
  Ensure that a user is logged in before proceeding to next route middleware.
  
  This middleware ensures that a user is logged in.  If a request is received
  that is unauthenticated, the request will be redirected to a login page (by
  default to `/login`).
  
  Additionally, `returnTo` will be be set in the session to the URL of the
  current request.  After authentication, this value can be used to redirect
  the user to the page that was originally requested.
  
  Options:
  - `redirectTo`   URL to redirect to for login, defaults to _/login_
  - `setReturnTo`  set redirectTo in session, defaults to _true_
  
  Examples:
  
  app.get('/profile',
  ensureLoggedIn(),
  function(req, res) { ... });
  
  app.get('/profile',
  ensureLoggedIn('/signin'),
  function(req, res) { ... });
  
  app.get('/profile',
  ensureLoggedIn({ redirectTo: '/session/new', setReturnTo: false }),
  function(req, res) { ... });
  
  
  @param {Object|String} options
  @return {Function}
  @api public