salix/services/production/server/middleware/currentUser.js

14 lines
385 B
JavaScript
Raw Normal View History

2017-06-14 06:54:45 +00:00
module.exports = function(options) {
return function storeCurrentUser(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();
};
};