File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -285,18 +285,21 @@ export class InvitationService {
285
285
}
286
286
287
287
// If accepted, then map user as cohort admin
288
- if ( invitation . invitationStatus === "Accepted" ) {
288
+ if ( request . body . invitationStatus === "Accepted" ) {
289
289
// Get role for roleId
290
290
const role = await this . roleRepository . findOne ( {
291
291
where : { tenantId : invitation . tenantId , code : "cohort_admin" } ,
292
292
} ) ;
293
293
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
295
295
const userRoleMap = await this . userRoleMappingRepository . findOne ( {
296
296
where : { userId, roleId : role . roleId } ,
297
297
} ) ;
298
+ const cohortMember = await this . cohortMembersRepository . findOne ( {
299
+ where : { cohortId : invitation . cohortId , userId } ,
300
+ } ) ;
298
301
299
- if ( userRoleMap ) {
302
+ if ( userRoleMap && cohortMember ) {
300
303
const error = API_RESPONSES . INVITEE_ALREADY_MAPPED ;
301
304
return APIResponse . error (
302
305
response ,
You can’t perform that action at this time.
0 commit comments