feat(auth): add bootstrap token flow for initial admin creation
- Introduced `BootstrapService` to handle admin creation when no admins exist. - Added `/auth/bootstrap-admin` endpoint to consume bootstrap tokens. - Updated `RbacRepository` to support counting admins and assigning roles. - Included unit tests for `BootstrapService` to ensure token behavior and admin assignment.
This commit is contained in:
@@ -51,4 +51,12 @@ export class RbacService implements OnApplicationBootstrap {
|
||||
async getUserPermissions(userId: string) {
|
||||
return this.rbacRepository.findPermissionsByUserId(userId);
|
||||
}
|
||||
|
||||
async countAdmins() {
|
||||
return this.rbacRepository.countAdmins();
|
||||
}
|
||||
|
||||
async assignRoleToUser(userId: string, roleSlug: string) {
|
||||
return this.rbacRepository.assignRole(userId, roleSlug);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user