diff --git a/lib/cartodb/controllers/named_maps.js b/lib/cartodb/controllers/named_maps.js index f668d638..f3aff5bd 100644 --- a/lib/cartodb/controllers/named_maps.js +++ b/lib/cartodb/controllers/named_maps.js @@ -16,6 +16,17 @@ function numMapper(n) { return +n; } +function getRequestParams(locals) { + const params = Object.assign({}, locals); + + delete params.template; + delete params.affectedTablesAndLastUpdate; + delete params.namedMapProvider; + delete params.allowedQueryParams; + + return params; +} + function NamedMapsController(prepareContext, namedMapProviderCache, tileBackend, previewBackend, surrogateKeysCache, tablesExtentApi, metadataBackend) { this.namedMapProviderCache = namedMapProviderCache; @@ -74,8 +85,9 @@ NamedMapsController.prototype.getNamedMapProvider = function (label) { const { user } = res.locals; const { config, auth_token } = req.query; const { template_id } = req.params; + const params = getRequestParams(res.locals); - this.namedMapProviderCache.get(user, template_id, config, auth_token, res.locals, (err, namedMapProvider) => { + this.namedMapProviderCache.get(user, template_id, config, auth_token, params, (err, namedMapProvider) => { if (err) { err.label = label; return next(err); @@ -146,11 +158,13 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (la return next(); } + const params = getRequestParams(res.locals); + // overwrites 'all' default filter - res.locals.layer = layerVisibilityFilter.join(','); + params.layer = layerVisibilityFilter.join(','); // recreates the provider - this.namedMapProviderCache.get(user, template_id, config, auth_token, res.locals, (err, provider) => { + this.namedMapProviderCache.get(user, template_id, config, auth_token, params, (err, provider) => { if (err) { err.label = label; return next(err);