Pass a copy of res.locals w/o new data boud to named-map-provider-cache

This commit is contained in:
Daniel García Aubert 2018-01-15 17:08:54 +01:00
parent 4ba2632a92
commit b82767c60d

View File

@ -74,8 +74,9 @@ NamedMapsController.prototype.getNamedMapProvider = function (label) {
const { user } = res.locals;
const { config, auth_token } = req.query;
const { template_id } = req.params;
const params = Object.assign({}, 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 +147,17 @@ NamedMapsController.prototype.prepareLayerFilterFromPreviewLayers = function (la
return next();
}
const params = Object.assign({}, res.locals);
delete params.template;
delete params.affectedTablesAndLastUpdate;
delete params.namedMapProvider;
// 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);