Moves setDBParams to serverOptions so it can be reused

This commit is contained in:
Raul Ochoa 2015-04-27 14:47:58 +02:00
parent 8503a5c7c9
commit e7bd5dd644
2 changed files with 16 additions and 17 deletions

View File

@ -302,7 +302,7 @@ TemplateMapsController.prototype.instantiateTemplate = function(req, res, templa
res: res,
profiler: req.profiler
};
self.setDBParams(cdbuser, fakereq.params, this);
self.serverOptions.setDBParams(cdbuser, fakereq.params, this);
},
function setApiKey(err){
if ( req.profiler ) req.profiler.done('setDBParams');
@ -343,22 +343,6 @@ TemplateMapsController.prototype.finish_instantiation = function(err, response,
}
};
TemplateMapsController.prototype.setDBParams = function(cdbuser, params, callback) {
var self = this;
step(
function setAuth() {
self.pgConnection.setDBAuth(cdbuser, params, this);
},
function setConn(err) {
if ( err ) throw err;
self.pgConnection.setDBConn(cdbuser, params, this);
},
function finish(err) {
callback(err);
}
);
};
function finishFn(app, res, description, okResponse) {
return function finish(err, response){
var statusCode = 200;

View File

@ -509,6 +509,21 @@ module.exports = function(redisPool) {
);
};
me.setDBParams = function(cdbuser, params, callback) {
step(
function setAuth() {
pgConnection.setDBAuth(cdbuser, params, this);
},
function setConn(err) {
if ( err ) throw err;
pgConnection.setDBConn(cdbuser, params, this);
},
function finish(err) {
callback(err);
}
);
};
// jshint maxcomplexity:10
/**
* Whitelist input and get database name & default geometry type from