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();
|
|
|
|
|
2019-01-07 07:41:54 +00:00
|
|
|
if (loopbackContext)
|
2017-10-13 14:22:45 +00:00
|
|
|
loopbackContext.set('currentUser', req.accessToken.userId);
|
2019-01-07 07:41:54 +00:00
|
|
|
|
2017-10-13 14:22:45 +00:00
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|