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:
parent
4c8ad2908b
commit
5978cb4919
|
@ -124,7 +124,7 @@ function token(options) {
|
||||||
TokenModel.findForRequest(req, options, function(err, token) {
|
TokenModel.findForRequest(req, options, function(err, token) {
|
||||||
req.accessToken = token || null;
|
req.accessToken = token || null;
|
||||||
rewriteUserLiteral(req, currentUserLiteral);
|
rewriteUserLiteral(req, currentUserLiteral);
|
||||||
var ctx = loopback.getCurrentContext();
|
var ctx = req.loopbackContext;
|
||||||
if (ctx) ctx.set('accessToken', token);
|
if (ctx) ctx.set('accessToken', token);
|
||||||
next(err);
|
next(err);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue