res.locals in map controller
This commit is contained in:
@@ -94,11 +94,11 @@ MapController.prototype.register = function(app) {
|
||||
MapController.prototype.createGet = function(req, res, next){
|
||||
req.profiler.start('windshaft.createmap_get');
|
||||
|
||||
this.create(req, res, function createGet$prepareConfig(req) {
|
||||
if ( ! req.params.config ) {
|
||||
this.create(req, res, function createGet$prepareConfig(req, config) {
|
||||
if ( ! config ) {
|
||||
throw new Error('layergroup GET needs a "config" parameter');
|
||||
}
|
||||
return JSON.parse(req.params.config);
|
||||
return JSON.parse(config);
|
||||
}, next);
|
||||
};
|
||||
|
||||
@@ -155,7 +155,7 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
||||
|
||||
step(
|
||||
function prepareConfig () {
|
||||
const requestMapConfig = prepareConfigFn(req);
|
||||
const requestMapConfig = prepareConfigFn(req, res.locals.config);
|
||||
return requestMapConfig;
|
||||
},
|
||||
function prepareAdapterMapConfig(err, requestMapConfig) {
|
||||
@@ -163,18 +163,18 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
||||
context.analysisConfiguration = {
|
||||
user: req.context.user,
|
||||
db: {
|
||||
host: req.params.dbhost,
|
||||
port: req.params.dbport,
|
||||
dbname: req.params.dbname,
|
||||
user: req.params.dbuser,
|
||||
pass: req.params.dbpassword
|
||||
host: res.locals.dbhost,
|
||||
port: res.locals.dbport,
|
||||
dbname: res.locals.dbname,
|
||||
user: res.locals.dbuser,
|
||||
pass: res.locals.dbpassword
|
||||
},
|
||||
batch: {
|
||||
username: req.context.user,
|
||||
apiKey: req.params.api_key
|
||||
apiKey: res.locals.api_key
|
||||
}
|
||||
};
|
||||
self.mapConfigAdapter.getMapConfig(req.context.user, requestMapConfig, req.params, context, this);
|
||||
self.mapConfigAdapter.getMapConfig(req.context.user, requestMapConfig, res.locals, context, this);
|
||||
},
|
||||
function createLayergroup(err, requestMapConfig) {
|
||||
assert.ifError(err);
|
||||
@@ -182,7 +182,7 @@ MapController.prototype.create = function(req, res, prepareConfigFn, next) {
|
||||
mapConfig = new MapConfig(requestMapConfig, datasource);
|
||||
self.mapBackend.createLayergroup(
|
||||
mapConfig, req.params,
|
||||
new CreateLayergroupMapConfigProvider(mapConfig, req.context.user, self.userLimitsApi, req.params),
|
||||
new CreateLayergroupMapConfigProvider(mapConfig, req.context.user, self.userLimitsApi, res.locals),
|
||||
this
|
||||
);
|
||||
},
|
||||
@@ -257,8 +257,8 @@ MapController.prototype.instantiateTemplate = function(req, res, prepareParamsFn
|
||||
cdbuser,
|
||||
req.params.template_id,
|
||||
templateParams,
|
||||
req.query.auth_token,
|
||||
req.params
|
||||
res.locals.auth_token,
|
||||
res.locals
|
||||
);
|
||||
mapConfigProvider.getMapConfig(this);
|
||||
},
|
||||
@@ -344,7 +344,7 @@ function(req, res, mapconfig, layergroup, analysesResults, callback) {
|
||||
}
|
||||
});
|
||||
|
||||
var dbName = req.params.dbname;
|
||||
var dbName = res.locals.dbname;
|
||||
var layergroupId = layergroup.layergroupid;
|
||||
var dbConnection;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user