rez_core 2.0.78 → 2.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rez_core",
3
- "version": "2.0.78",
3
+ "version": "2.0.80",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "private": false,
@@ -22,16 +22,13 @@ export class RoleService extends EntityServiceImpl {
22
22
 
23
23
  async createEntity(
24
24
  entityData: BaseEntity,
25
- loggedInUser: UserData | null,
26
- manager?: EntityManager,
27
- appcode?: string,
25
+ loggedInUser: UserData,
28
26
  ): Promise<BaseEntity> {
29
27
  let role = entityData as Role;
30
28
 
31
- if (loggedInUser?.level_type && loggedInUser?.level_id) {
32
- role.level_type = loggedInUser.level_type;
33
- role.level_id = loggedInUser.level_id;
34
- }
29
+ // if level_type and level_id are not provided, use loggedInUser's values
30
+ role.level_type = entityData.level_type || loggedInUser.level_type;
31
+ role.level_id = entityData.level_id || loggedInUser.level_id;
35
32
 
36
33
  if (
37
34
  await this.roleRepository.isRoleNameWithLevelExists(role.name, {
@@ -187,10 +187,13 @@ export class UserService extends EntityServiceImpl {
187
187
 
188
188
  // Handle updated access levels
189
189
  if (userDto.access && userDto.access.length > 0) {
190
+ // delete all the existing user role mapping
191
+ await this.userRoleMappingService.deleteByUserId(existingUser.id);
192
+
190
193
  const insertPromises: any[] = [];
191
194
 
192
195
  for (const entry of userDto.access) {
193
- const { id, level_type, level_ids, app_code, role_id } = entry;
196
+ const { level_type, level_ids, app_code, role_id } = entry;
194
197
 
195
198
  if (!level_type || !app_code || !role_id || !Array.isArray(level_ids)) {
196
199
  throw new BadRequestException('Invalid access level entry');
@@ -199,10 +202,6 @@ export class UserService extends EntityServiceImpl {
199
202
  for (const levelId of level_ids) {
200
203
  const userRoleMapping = new UserRoleMapping(savedData.id, role_id);
201
204
 
202
- if (id) {
203
- userRoleMapping.id = id; // Use the existing ID if provided
204
- }
205
-
206
205
  userRoleMapping.level_type = level_type;
207
206
  userRoleMapping.level_id = String(levelId);
208
207
  userRoleMapping.appcode = app_code;