diff --git a/lib/nowServerLib.js b/lib/nowServerLib.js index 1991e2a..72b0eaf 100644 --- a/lib/nowServerLib.js +++ b/lib/nowServerLib.js @@ -60,7 +60,8 @@ var nowCore = { // Create proxy object - nowCore.proxies[client.sessionId] = proxy.wrap(nowCore.constructClientScopeStore(client), scope, client.sessionId); + client.user = client.user ? client.user : {clientId: client.sessionId}; + nowCore.proxies[client.sessionId] = proxy.wrap(nowCore.constructClientScopeStore(client), scope, client.user); nowCore.scopes[client.sessionId] = scope; nowCore.clientGroups[client.sessionId] = []; diff --git a/lib/wrap.js b/lib/wrap.js index d34ade6..1901671 100644 --- a/lib/wrap.js +++ b/lib/wrap.js @@ -1,6 +1,6 @@ var Proxy = require('node-proxy'); -exports.wrap = function (store, sessions, clientId) { +exports.wrap = function (store, sessions, user) { var taint = {}; var taintedFqns = {}; var set = store ? (store.set || store.save).bind(store) : null; @@ -13,8 +13,8 @@ exports.wrap = function (store, sessions, clientId) { else { var returnObj = wrapRoot(name, sessions[name], '["'+name+'"]', theProxy); if(typeof returnObj === 'function' && sessions.hasOwnProperty(name)){ - if(clientId){ - returnObj = returnObj.bind({now: theProxy, user:{clientId: clientId}}); + if(user){ + returnObj = returnObj.bind({now: theProxy, user:user}); } else { returnObj = returnObj.bind({now: theProxy}); }