Skip to content

Commit 6896dc6

Browse files
Update Invitation API Issue Fix
1 parent 3d4bfa5 commit 6896dc6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/invitation/invitation.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,21 @@ export class InvitationService {
285285
}
286286

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

294-
// Check if user is already mapped as cohort admin or not
294+
// Check if user is already mapped as cohort admin for given cohort or not
295295
const userRoleMap = await this.userRoleMappingRepository.findOne({
296296
where: { userId, roleId: role.roleId },
297297
});
298+
const cohortMember = await this.cohortMembersRepository.findOne({
299+
where: { cohortId: invitation.cohortId, userId },
300+
});
298301

299-
if (userRoleMap) {
302+
if (userRoleMap && cohortMember) {
300303
const error = API_RESPONSES.INVITEE_ALREADY_MAPPED;
301304
return APIResponse.error(
302305
response,

0 commit comments

Comments
 (0)