not move db params to res.locals.db
This commit is contained in:
parent
f824fc5243
commit
b4d03c074a
@ -105,7 +105,7 @@ AuthApi.prototype.authorize = function(req, res, callback) {
|
||||
}
|
||||
|
||||
// authorized by api key, login as the given username and stop
|
||||
self.pgConnection.setDBAuth(user, res.locals.db, function(err) {
|
||||
self.pgConnection.setDBAuth(user, res.locals, function(err) {
|
||||
callback(err, true); // authorized (or error)
|
||||
});
|
||||
},
|
||||
@ -128,7 +128,7 @@ AuthApi.prototype.authorize = function(req, res, callback) {
|
||||
return callback(null, false);
|
||||
}
|
||||
|
||||
self.pgConnection.setDBAuth(user, res.locals.db, function(err) {
|
||||
self.pgConnection.setDBAuth(user, res.locals, function(err) {
|
||||
req.profiler.done('setDBAuth');
|
||||
callback(err, true); // authorized (or error)
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ AnalysesController.prototype.catalog = function (req, res, next) {
|
||||
|
||||
step(
|
||||
function catalogQuery() {
|
||||
var pg = new PSQL(dbParamsFromReqParams(res.locals.db));
|
||||
var pg = new PSQL(dbParamsFromReqParams(res.locals));
|
||||
getMetadata(username, pg, this);
|
||||
},
|
||||
function prepareResponse(err, results) {
|
||||
|
@ -7,8 +7,8 @@ module.exports = BaseController;
|
||||
|
||||
// jshint maxcomplexity:9
|
||||
BaseController.prototype.send = function(req, res, body, status, headers) {
|
||||
if (res.locals.db.dbhost) {
|
||||
res.set('X-Served-By-DB-Host', res.locals.db.dbhost);
|
||||
if (res.locals.dbhost) {
|
||||
res.set('X-Served-By-DB-Host', res.locals.dbhost);
|
||||
}
|
||||
|
||||
res.set('X-Tiler-Profiler', req.profiler.toJSONString());
|
||||
|
@ -4,8 +4,7 @@ module.exports = function dbConnSetupMiddleware(pgConnection) {
|
||||
return function (req, res, next) {
|
||||
const user = req.context.user;
|
||||
|
||||
res.locals.db = {}
|
||||
pgConnection.setDBConn(user, res.locals.db, (err) => {
|
||||
pgConnection.setDBConn(user, res.locals, (err) => {
|
||||
if (err) {
|
||||
if (err.message && -1 !== err.message.indexOf('name not found')) {
|
||||
err.http_status = 404;
|
||||
@ -16,7 +15,7 @@ module.exports = function dbConnSetupMiddleware(pgConnection) {
|
||||
|
||||
// Add default database connection parameters
|
||||
// if none given
|
||||
_.defaults(res.locals.db, {
|
||||
_.defaults(res.locals, {
|
||||
dbuser: global.environment.postgres.user,
|
||||
dbpassword: global.environment.postgres.password,
|
||||
dbhost: global.environment.postgres.host,
|
||||
|
Loading…
Reference in New Issue
Block a user