1.0.3 • Published 5 years ago

@itemsjs/service-user v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

ItemsJS User service

NPM version NPM downloads

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