15 lines
388 B
JavaScript
15 lines
388 B
JavaScript
module.exports = function(options) {
|
|
return function(req, res, next) {
|
|
if (!req.accessToken)
|
|
return next();
|
|
|
|
let LoopBackContext = require('loopback-context');
|
|
let loopbackContext = LoopBackContext.getCurrentContext();
|
|
|
|
if (loopbackContext)
|
|
loopbackContext.set('currentUser', req.accessToken.userId);
|
|
|
|
next();
|
|
};
|
|
};
|