code: function authRequired (req, res, next) {
    if (!req.user) {
      req.session.oauth2return = req.originalUrl;
      return res.redirect('/login');
    }
    if (req.session.allowedDomain && req.session.allowedDomain !== req.user.domain) {
      return res.redirect('/login');
    }
    next();
  }
docs: [START middleware] Middleware that requires the user to be logged in. If the user is not logged in, it will redirect the user to authorize the application and then return them to the original URL they requested.