Skip to content

Commit

Permalink
Merge pull request #24 from Vidyaranya-Gavai-TTPL/updateInvitationFix
Browse files Browse the repository at this point in the history
Update Invitation API Issue Fix
  • Loading branch information
sudeeppr1998 authored Feb 11, 2025
2 parents 7c65bef + 6896dc6 commit 43b8086
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/invitation/invitation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,21 @@ export class InvitationService {
}

// If accepted, then map user as cohort admin
if (invitation.invitationStatus === "Accepted") {
if (request.body.invitationStatus === "Accepted") {
// Get role for roleId
const role = await this.roleRepository.findOne({
where: { tenantId: invitation.tenantId, code: "cohort_admin" },
});

// Check if user is already mapped as cohort admin or not
// Check if user is already mapped as cohort admin for given cohort or not
const userRoleMap = await this.userRoleMappingRepository.findOne({
where: { userId, roleId: role.roleId },
});
const cohortMember = await this.cohortMembersRepository.findOne({
where: { cohortId: invitation.cohortId, userId },
});

if (userRoleMap) {
if (userRoleMap && cohortMember) {
const error = API_RESPONSES.INVITEE_ALREADY_MAPPED;
return APIResponse.error(
response,
Expand Down

0 comments on commit 43b8086

Please sign in to comment.