Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug in wrap.js with binding functions properly

  • Loading branch information...
commit 613e379cd35349d212444d698a0267897dcabde5 1 parent 87f4f85
Sridatta Thatipamala authored
Showing with 16 additions and 12 deletions.
  1. +1 −1  lib/nowServerLib.js
  2. +15 −11 lib/wrap.js
View
2  lib/nowServerLib.js
@@ -60,7 +60,7 @@ var nowCore = {
// Create proxy object
- nowCore.proxies[client.sessionId] = proxy.wrap(nowCore.constructClientScopeStore(client), scope);
+ nowCore.proxies[client.sessionId] = proxy.wrap(nowCore.constructClientScopeStore(client), scope, client.sessionId);
nowCore.scopes[client.sessionId] = scope;
nowCore.clientGroups[client.sessionId] = [];
View
26 lib/wrap.js
@@ -1,22 +1,26 @@
var Proxy = require('node-proxy');
-exports.wrap = function (store, sessions) {
+exports.wrap = function (store, sessions, clientId) {
var taint = {};
var taintedFqns = {};
var set = store ? (store.set || store.save).bind(store) : null;
var theProxy = Proxy.create({
get : function (recv, name) {
- if (name === 'toJSON' && !sessions.hasOwnProperty(name)) {
- return function () { return sessions }
- }
- else {
- var returnObj = wrapRoot(name, sessions[name], '["'+name+'"]', theProxy);
- if(typeof returnObj === 'function' && sessions.hasOwnProperty(name)){
- returnObj = returnObj.bind({now: theProxy})
- }
- return returnObj;
- }
+ if (name === 'toJSON' && !sessions.hasOwnProperty(name)) {
+ return function () { return sessions; };
+ }
+ 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}});
+ } else {
+ returnObj = returnObj.bind({now: theProxy});
+ }
+ }
+ return returnObj;
+ }
},
set : function (recv, name, value) {
sessions[name] = value;
Please sign in to comment.
Something went wrong with that request. Please try again.