From 22f8a46ead82a24e12bebd723a1db9f14460e024 Mon Sep 17 00:00:00 2001 From: josieusa Date: Wed, 22 Feb 2017 18:15:25 +0100 Subject: [PATCH] Fix mixed up ctx in middlewares after a bad one --- server/current-context.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/current-context.js b/server/current-context.js index 4bbd93e..ebb9103 100644 --- a/server/current-context.js +++ b/server/current-context.js @@ -86,13 +86,15 @@ LoopBackContext.createContext = function(scopeName) { } /** * **NOTE** - * This only re-binds get and set methods, the most used. + * This only re-binds get, set and bind methods, the most used. * If you use other methods of the context, e.g. runInContext(), etc., * you may run into unexpected issues that are fixed only for get & set. */ var boundContext = Object.create(ns); - boundContext.get = ns.bind(ns.get); - boundContext.set = ns.bind(ns.set); + // Call to Function.prototype.bind(), not ns.bind() + boundContext.bind = ns.bind.bind(ns); + boundContext.get = boundContext.bind(ns.get); + boundContext.set = boundContext.bind(ns.set); return boundContext; }; }