loopback-component-currentuser
v1.0.1
Published
loopback3 component currenUser
Downloads
7
Maintainers
Readme
Loopback current user component
Base on loopback3 current context package current user for loopback operation hooks
Install
> npm install loopback-component-currentuser
Config
./server/component-config.json
{
...
"loopback-component-currentuser": {
"filter" : {
"include": ["userIdentities", "userCredentials"]
},
"user": "user"
}
...
}
Usage
'use strict';
module.exports = (Deal) => {
Deal.observe('before save', (ctx, next)=>{
if (ctx.instance) {
if (ctx.isNewInstance) {
if (ctx.options.accessToken) {
console.log(ctx.options.currentUser);
}
}
next();
} else {
next();
}
});
};