Skip to content

Commit

Permalink
fix(core): Fix returning stale data in Role Update Event (#3154)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielBiegler authored Nov 14, 2024
1 parent 7324bb3 commit 71f85d2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/core/src/service/services/role.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,20 @@ export class RoleService {
input.permissions,
);
}
const updatedRole = patchEntity(role, {
patchEntity(role, {
code: input.code,
description: input.description,
permissions: input.permissions
? unique([Permission.Authenticated, ...input.permissions])
: undefined,
});
if (targetChannels) {
updatedRole.channels = targetChannels;
role.channels = targetChannels;
}
await this.connection.getRepository(ctx, Role).save(updatedRole, { reload: false });
await this.eventBus.publish(new RoleEvent(ctx, role, 'updated', input));
return await assertFound(this.findOne(ctx, role.id));
await this.connection.getRepository(ctx, Role).save(role, { reload: false });
const updatedRole = await assertFound(this.findOne(ctx, role.id));
await this.eventBus.publish(new RoleEvent(ctx, updatedRole, 'updated', input));
return updatedRole;
}

async delete(ctx: RequestContext, id: ID): Promise<DeletionResponse> {
Expand Down

0 comments on commit 71f85d2

Please sign in to comment.