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
pull/90/head
moonrailgun 2 years ago
parent db1f5fb142
commit bad6aa05fa

@ -290,7 +290,7 @@ export class Group extends TimeStamps implements Base {
const allRoles = member.roles; const allRoles = member.roles;
const allRolesPermission = allRoles.map((roleName) => { 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 ?? []; return p?.permissions ?? [];
}); });

@ -897,6 +897,7 @@ class GroupService extends TcService {
) )
.exec(); .exec();
this.cleanGroupInfoCache(groupId);
const json = await this.notifyGroupInfoUpdate(ctx, group); const json = await this.notifyGroupInfoUpdate(ctx, group);
return json; return json;
} }
@ -936,6 +937,7 @@ class GroupService extends TcService {
) )
.exec(); .exec();
this.cleanGroupInfoCache(groupId);
const json = await this.notifyGroupInfoUpdate(ctx, group); const json = await this.notifyGroupInfoUpdate(ctx, group);
return json; return json;
} }
@ -968,6 +970,7 @@ class GroupService extends TcService {
roleName roleName
); );
this.cleanGroupInfoCache(groupId);
const json = await this.notifyGroupInfoUpdate(ctx, group); const json = await this.notifyGroupInfoUpdate(ctx, group);
return json; return json;
} }
@ -1000,6 +1003,8 @@ class GroupService extends TcService {
permissions permissions
); );
this.cleanGroupInfoCache(groupId);
this.cleanGroupAllUserPermissionCache(groupId);
const json = await this.notifyGroupInfoUpdate(ctx, group); const json = await this.notifyGroupInfoUpdate(ctx, group);
return json; return json;
} }

Loading…
Cancel
Save