Always replace the database user parameter in the XML style

This provides for an automatic migration of styles to any new
authentication user.
This commit is contained in:
Sandro Santilli 2012-09-05 15:41:22 +02:00
parent c3091e50fc
commit 5ca84d9ffc

View File

@ -36,11 +36,9 @@ module.exports = function(){
req.params.interactivity = req.params.interactivity || 'cartodb_id';
req.params.processXML = function(req, xml, callback) {
if ( req.dbuser ) {
// Only edit XML when authenticated
if ( ! me.rx_dbuser ) me.rx_dbuser = /(<Parameter name="user"><!\[CDATA\[)[^\]]*(]]><\/Parameter>)/;
xml = xml.replace(me.rx_dbuser, "$1" + req.dbuser + "$2");
}
var dbuser = req.dbuser ? req.dbuser : global.settings.postgres.user;
if ( ! me.rx_dbuser ) me.rx_dbuser = /(<Parameter name="user"><!\[CDATA\[)[^\]]*(]]><\/Parameter>)/;
xml = xml.replace(me.rx_dbuser, "$1" + dbuser + "$2");
callback(null, xml);
}