Skip to content

Commit

Permalink
Merge pull request #21 from vishnuvinay89/all-saas-0.2-dev
Browse files Browse the repository at this point in the history
Bug #233491 - Duplicate Tenant Name Allowed During Update
  • Loading branch information
sudeeppr1998 authored Feb 7, 2025
2 parents 5954fe1 + b311571 commit 234e37c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/tenant/tenant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,21 @@ export class TenantService {
HttpStatus.CONFLICT
);
}
let checkExistTenants = await this.tenantRepository.find({
where: {
"name": tenantUpdateDto?.name
}
}
)
if (checkExistTenants.length > 0) {
return APIResponse.error(
response,
apiId,
API_RESPONSES.CONFLICT,
API_RESPONSES.TENANT_NAME_EXISTS(tenantUpdateDto?.name),
HttpStatus.CONFLICT
);
}

let result = await this.tenantRepository.update(
tenantId,
Expand Down Expand Up @@ -357,11 +372,11 @@ export class TenantService {
const createPrivilegeRoleDto = new CreatePrivilegeRoleDto(privilegeMappingRequest)
// Call to map privileges to the role
await this.rolePrivilegeService.createPrivilegeRole(request as any, createPrivilegeRoleDto, response as any);
return rolesResult;
} else {
console.warn(`No privileges found for role "${roleCode}".`);
}
}
return rolesResult;
} catch (error) {
console.error("Error while creating roles and assigning privileges:", error.message);
throw error;
Expand Down

0 comments on commit 234e37c

Please sign in to comment.