This commit is contained in:
Ahmed Bouhuolia
2026-01-16 00:23:16 +02:00
parent 2bbc154f18
commit c21301061f
15 changed files with 87 additions and 45 deletions

View File

@@ -17,7 +17,7 @@ export class EditRoleService {
@Inject(Role.name)
private readonly roleModel: TenantModelProxy<typeof Role>,
) {}
) { }
/**
* Edits details of the given role on the storage.
@@ -30,7 +30,13 @@ export class EditRoleService {
// Retrieve the given role or throw not found serice error.
const oldRole = await this.roleModel().query().findById(roleId);
const permissions = editRoleDTO.permissions;
// Transform permissions: map permissionId to id for Objection.js upsertGraph
const permissions = editRoleDTO.permissions.map((perm) => ({
id: perm.permissionId,
subject: perm.subject,
ability: perm.ability,
value: perm.value,
}));
// Updates the role on the storage.
return this.uow.withTransaction(async (trx: Knex.Transaction) => {