Add privilege management system with related migrations and guards
- Introduced a new `PrivilegesModule` to manage user privileges and access control. - Added `RequirePrivilege` decorator to enforce privilege checks on controller handlers. - Implemented `PrivilegesGuard` to handle authorization based on user privileges. - Created database migrations for `privileges`, `privilege_keys`, and `privilege_details` tables. - Updated user model to include `is_superadmin` field for enhanced access control. - Added unit tests for the new privileges functionality and guards to ensure correct behavior.
This commit is contained in:
@@ -5,6 +5,8 @@ import { AppController } from '../../app.controller';
|
||||
import { AppService } from '../../app.service';
|
||||
import { AuthController } from '../../modules/auth/auth.controller';
|
||||
import { AuthService } from '../../modules/auth/auth.service';
|
||||
import { PrivilegesService } from '../../modules/privileges/privileges.service';
|
||||
import { UsersService } from '../../modules/users/users.service';
|
||||
import {
|
||||
createOpenApiDocument,
|
||||
isSwaggerEnabled,
|
||||
@@ -56,6 +58,17 @@ describe('createOpenApiDocument', () => {
|
||||
revoke: jest.fn(),
|
||||
},
|
||||
},
|
||||
{
|
||||
provide: UsersService,
|
||||
useValue: { findById: jest.fn() },
|
||||
},
|
||||
{
|
||||
provide: PrivilegesService,
|
||||
useValue: {
|
||||
findPrivilegeSummary: jest.fn(),
|
||||
getPermissionsMap: jest.fn(),
|
||||
},
|
||||
},
|
||||
],
|
||||
}).compile();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user