From 17358d288f9b316771eaaa2e3d03c3f0ab328742 Mon Sep 17 00:00:00 2001 From: Vidyaranya-Gavai-TTPL Date: Thu, 13 Feb 2025 15:03:11 +0530 Subject: [PATCH] Issue Fixed --- src/invitation/invitation.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/invitation/invitation.service.ts b/src/invitation/invitation.service.ts index a63ef6e..44f8d1e 100644 --- a/src/invitation/invitation.service.ts +++ b/src/invitation/invitation.service.ts @@ -286,7 +286,7 @@ export class InvitationService { } // If accepted, then map user as cohort admin - if (invitation.invitationStatus === "Accepted") { + if (updateInvitationDto.invitationStatus === "Accepted") { // Get role for roleId const role = await this.roleRepository.findOne({ where: { tenantId: invitation.tenantId, code: "cohort_admin" }, @@ -297,7 +297,11 @@ export class InvitationService { where: { userId, roleId: role.roleId }, }); - if (userRoleMap) { + const cohortMember = await this.cohortMembersRepository.findOne({ + where: { cohortId: invitation.cohortId, userId }, + }) + + if (userRoleMap && cohortMember) { const error = API_RESPONSES.INVITEE_ALREADY_MAPPED; return APIResponse.error( response,