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/dist/module/user/service/role.service.d.ts +1 -1
- package/dist/module/user/service/role.service.js +3 -5
- package/dist/module/user/service/role.service.js.map +1 -1
- package/dist/module/user/service/user.service.js +2 -4
- package/dist/module/user/service/user.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/user/service/role.service.ts +4 -7
- package/src/module/user/service/user.service.ts +4 -5
package/package.json
CHANGED
|
@@ -22,16 +22,13 @@ export class RoleService extends EntityServiceImpl {
|
|
|
22
22
|
|
|
23
23
|
async createEntity(
|
|
24
24
|
entityData: BaseEntity,
|
|
25
|
-
loggedInUser: UserData
|
|
26
|
-
manager?: EntityManager,
|
|
27
|
-
appcode?: string,
|
|
25
|
+
loggedInUser: UserData,
|
|
28
26
|
): Promise<BaseEntity> {
|
|
29
27
|
let role = entityData as Role;
|
|
30
28
|
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
|
|
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 {
|
|
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;
|