From 8574517ab830aa1fa9602e26bfe01c7a2562524f Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 18 Oct 2012 11:33:35 +0200 Subject: [PATCH] Add a userid_to_dbuser function --- app/controllers/app.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/controllers/app.js b/app/controllers/app.js index 7cc47c3f..6dafd9a0 100755 --- a/app/controllers/app.js +++ b/app/controllers/app.js @@ -53,6 +53,15 @@ function queryMayWrite(sql) { return mayWrite; } +// Return database username from user_id +// NOTE: a "null" user_id is a request to use the public user +function userid_to_dbuser(user_id) { + if ( _.isString(user_id) ) + return _.template(global.settings.db_user, {user_id: user_id}); + return "publicuser" // FIXME: make configurable +}; + + // request handlers function handleQuery(req, res) {