1.0.3 • Published 6 years ago
@itemsjs/service-user v1.0.3
ItemsJS User service
Installation
npm i @itemsjs/service-user --save
Usage
const UserService = require('@itemsjs/service-user');
let userService = new UserService();
if(!userService.attached) {
userService.attach({
id: 'user-id-1',
roles: ['role1', 'role2'],
permissions: ['p1', 'p2', 'p3' ,'p4']
});
}
if(userService.isInRole('role1')) {
// Do something here
}
// or check if user has permission
if(userService.hasPermission('p1')) {
// Do something here
}
And you're good to go!
License
MIT