Fix token middleware to not trigger CLS init

Rework the token middleware to access current context via
`req.loopbackContext` instead of `loopback.getCurentContext()`.
That way the CLS/AsyncListener machinery is configured only in
applications that are using current context.
This commit is contained in:
Miroslav Bajtoš 2016-08-10 15:26:14 +02:00
parent 4c8ad2908b
commit 5978cb4919
1 changed files with 1 additions and 1 deletions

View File

@ -124,7 +124,7 @@ function token(options) {
TokenModel.findForRequest(req, options, function(err, token) {
req.accessToken = token || null;
rewriteUserLiteral(req, currentUserLiteral);
var ctx = loopback.getCurrentContext();
var ctx = req.loopbackContext;
if (ctx) ctx.set('accessToken', token);
next(err);
});