Add a userid_to_dbuser function

This commit is contained in:
Sandro Santilli 2012-10-18 11:33:35 +02:00
parent d399d2153f
commit 8574517ab8

View File

@ -53,6 +53,15 @@ function queryMayWrite(sql) {
return mayWrite; 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 // request handlers
function handleQuery(req, res) { function handleQuery(req, res) {