docs: function(requiredRoutes) {
        if (typeof requiredRoutes !== 'object') {
          requiredRoutes = {
            all: [ requiredRoutes !== undefined ? requiredRoutes : true ]
          };
        }
  
        return function(req, res, next) {
          var method          = req.method.toLowerCase()
            , user            = req.user
            , isAdmin         = !!user ? !!user.hasAdminRight : false
            , action          = req.params.action ? req.params.action.toLowerCase() : false
            , accountId       = (method === 'post') ? req.body.AccountId : (req.query.AccountId || parseInt(req.params.AccountId, 10))
            , routeEnabled    = false;
  
          if (!req.query.AccountId && !!accountId) {
            req.query.AccountId = accountId;
          }
  
          if (!action && method === 'get' && /^\/[^\/]+\/?$/ig.test(req.url)) {
            action = 'list';
          } else if (/^[0-9a-fA-F]{24}$/.test(action) || !isNaN(action)) {
            action = 'get';
          }
  
          async.waterfall(
            [
              function isRouteEnabled(callback) {
                var actionName = (!!action ? action : method) + 'Action';
  
                if (typeof requiredRoutes[ actionName ] !== 'undefined') {
                  if (requiredRoutes[ actionName ] !== null) {
                    if (requiredRoutes[ actionName ] === true) {
                      routeEnabled = true;
                    }
                  }
                } else if (typeof requiredRoutes.all !== 'undefined') {
                  if (requiredRoutes.all === true) {
                    routeEnabled = true;
                  }
                }
  
                callback(null);
              },
  
              function addAccountIdToRequest(callback) {
                if (routeEnabled === true) {
  
                  if (!user) {
                    
                    callback('Unknown user');
  
                  } else {
  
                    if (method === 'post' || method === 'put') {
                      if (!isAdmin || (!!isAdmin && !accountId)) {
                        req.body.AccountId = parseInt(!/^[0-9a-fA-F]{24}$/.test(user.Account.id) ? user.Account.id : user.Account._id, 10);
                      }
                    } else {
                      if (!isAdmin || (!!isAdmin && !accountId)) {
                        req.query.AccountId = parseInt(!/^[0-9a-fA-F]{24}$/.test(user.Account.id) ? user.Account.id : user.Account._id, 10);
                      }
                    }
  
                    callback(null);
                  }
  
                } else {
                  callback(null);
                }
              }
            ],
            function(err) {
              if (err === null) {
                next();
              } else {
                res.send(401, { statusCode: 401, message: err });
              }
            }
  
           );
        };
      }