2017-10-13 14:22:45 +00:00
|
|
|
module.exports = function(options) {
|
2018-01-29 11:37:54 +00:00
|
|
|
return function(req, res, next) {
|
|
|
|
if (!req.accessToken)
|
2017-10-13 14:22:45 +00:00
|
|
|
return next();
|
|
|
|
|
|
|
|
let LoopBackContext = require('loopback-context');
|
|
|
|
let loopbackContext = LoopBackContext.getCurrentContext();
|
|
|
|
|
|
|
|
if (loopbackContext) {
|
|
|
|
loopbackContext.set('currentUser', req.accessToken.userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|