loopback-component-current-user
v0.1.2
Published
get the current user from access token for Loopback.
Maintainers
Readme
Loopback Component Current User
This loopback component enables you to add the logined(current) user to the request of thhe loopback application.
Installation
- Install in you loopback project:
npm install --save loopback-component-current-user
Create a component-config.json file in your server folder (if you don't already have one)
Configure options inside
component-config.json:
{
"loopback-component-current-user": {
"user": "User"
}
}user- [String] : The name of the user model. (default: 'User')
Create a middleware.json file in your server folder (if you don't already have one).
Ensure that you enable the
loopback#tokenmiddleware early in your middleware chain.
{
"initial:before": {
"loopback#token": {}
},
}Usage
Model.beforeRemote('*', function(ctx, next){
console.log(ctx.req.currentUser)
})
