From 55f333c0b7d82b284100b3492c657314f692ff86 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 27 Feb 2014 16:40:59 +0100 Subject: [PATCH] Call userByReq() only once in req2params --- lib/cartodb/server_options.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index 4d94cfa6..f32d0835 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -707,6 +707,8 @@ module.exports = function(){ _.each(bad_query, function(key){ delete req.query[key]; }); req.params = _.extend({}, req.params); // shuffle things as request is a strange array/object + var user = me.userByReq(req); + if ( req.params.token ) { //console.log("Request parameters include token " + req.params.token); var tksplit = req.params.token.split(':'); @@ -715,7 +717,7 @@ module.exports = function(){ tksplit = req.params.token.split('@'); if ( tksplit.length > 1 ) { req.params.signer = tksplit.shift(); - if ( ! req.params.signer ) req.params.signer = this.userByReq(req); + if ( ! req.params.signer ) req.params.signer = user; if ( tksplit.length > 1 ) { var template_hash = tksplit.shift(); // unused } @@ -734,8 +736,6 @@ module.exports = function(){ if (req.profiler) req.profiler.done('req2params.setup'); - var user = me.userByReq(req); - Step( function getPrivacy(){ me.authorize(req, this);