@ampraveeen/nestjs-user-management v1.0.0
Description
Nestjs user management is npm package (for nestjs) for manage users,rbac & auth for lms project
Requirements
You need to have nestjs app with mogodb database. Setup MongooseModule first.
Installation
$ npm install nest-user-management
How to use
- In your AppModule file import UserAuthModule from nestjs-user-management and registet it with your configOption in imports
import { UserAuthModule } from 'nest-user-management';
.
.
.
imports: [...,
UserAuthModule.register({
authOptions,
jwtOptions:{
secret: 'your jwt secret',
signOptions: { expiresIn: 'jwt validity time' }
},
rbacOptions: {
AppPermissions:'your custom permissions array'
AppRoles:'your custom assign permissions array'
}
})
]
provide the cofiguration details as mentioned above.
Now you can access /auth , /users, /rbac APIs provided by package.
First Steps
Create a superadmin user.
now create default permissions.
now create vendor, teacher and student roles.
Setting Permission & Using Guards
Use JwtAuthGuard (from auth module) for setting jwt token authorization to API.
Use OrganizationGuard ( from organization module ) for APIs which need organizationId to complete.
To set permission to your API route use RolesGuard & setRoute (for setting unique api code to your route)
User RolesGuard (from rbac module ) for sverifying role permissions.
import { JwtAuthGuard, RolesGuard } from 'nest-user-management';
@Get('')
@UseGuards(JwtAuthGuard,RolesGuard)
@RouteCode('get_test_data')// unique api code
getHello() {
return this.service.gethello();
}
Notes
- If user register as vendor, after registration he needs to create an organization first.
Stay in touch
- Author - Praveen Sharma
- Website - https://amcipher.com
License
Nest is MIT licensed.
4 years ago