From bad6aa05fadcececafdf129254f35c5ef5f6b05e Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 28 May 2023 00:23:41 +0800 Subject: [PATCH] fix: fix check logic in getGroupUserPermission member role record role id, so filter should be use _id other than name and add cache clean login when edit group permission --- server/models/group/group.ts | 2 +- server/services/core/group/group.service.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/models/group/group.ts b/server/models/group/group.ts index daae7259..0f8b0ddd 100644 --- a/server/models/group/group.ts +++ b/server/models/group/group.ts @@ -290,7 +290,7 @@ export class Group extends TimeStamps implements Base { const allRoles = member.roles; const allRolesPermission = allRoles.map((roleName) => { - const p = group.roles.find((r) => r.name === roleName); + const p = group.roles.find((r) => String(r._id) === roleName); return p?.permissions ?? []; }); diff --git a/server/services/core/group/group.service.ts b/server/services/core/group/group.service.ts index 94794605..27de5d50 100644 --- a/server/services/core/group/group.service.ts +++ b/server/services/core/group/group.service.ts @@ -897,6 +897,7 @@ class GroupService extends TcService { ) .exec(); + this.cleanGroupInfoCache(groupId); const json = await this.notifyGroupInfoUpdate(ctx, group); return json; } @@ -936,6 +937,7 @@ class GroupService extends TcService { ) .exec(); + this.cleanGroupInfoCache(groupId); const json = await this.notifyGroupInfoUpdate(ctx, group); return json; } @@ -968,6 +970,7 @@ class GroupService extends TcService { roleName ); + this.cleanGroupInfoCache(groupId); const json = await this.notifyGroupInfoUpdate(ctx, group); return json; } @@ -1000,6 +1003,8 @@ class GroupService extends TcService { permissions ); + this.cleanGroupInfoCache(groupId); + this.cleanGroupAllUserPermissionCache(groupId); const json = await this.notifyGroupInfoUpdate(ctx, group); return json; }