diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 844778ab40..44b5939049 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -37,7 +37,7 @@ jobs: - name: Count number of lines run: | chmod +x ./.github/workflows/countline.py - ./.github/workflows/countline.py --lines 600 --exclude_files src/types/generatedGraphQLTypes.ts tests src/typeDefs/types.ts src/constants.ts + ./.github/workflows/countline.py --lines 600 --exclude_files src/types/generatedGraphQLTypes.ts tests src/typeDefs/types.ts src/constants.ts src/typeDefs/inputs.ts - name: Check for TSDoc comments run: npm run check-tsdoc # Run the TSDoc check script diff --git a/src/resolvers/Mutation/updateVolunteerMembership.ts b/src/resolvers/Mutation/updateVolunteerMembership.ts index aa376f344f..18d28e483d 100644 --- a/src/resolvers/Mutation/updateVolunteerMembership.ts +++ b/src/resolvers/Mutation/updateVolunteerMembership.ts @@ -78,31 +78,33 @@ export const updateVolunteerMembership: MutationResolvers["updateVolunteerMember .populate("organization") .lean()) as InterfaceEvent; - // Check if the user is authorized to update the volunteer membership - const isAdminOrSuperAdmin = await adminCheck( - currentUser._id, - event.organization, - false, - ); - const isEventAdmin = event.admins.some( - (admin) => admin.toString() == currentUser._id.toString(), - ); - let isGroupLeader = false; - if (volunteerMembership.group != undefined) { - // check if current user is group leader - const group = (await EventVolunteerGroup.findById( - volunteerMembership.group, - ).lean()) as InterfaceEventVolunteerGroup; - isGroupLeader = group.leader.toString() == currentUser._id.toString(); - } - - // If the user is not an admin or super admin, event admin, or group leader, throw an error - if (!isAdminOrSuperAdmin && !isEventAdmin && !isGroupLeader) { - throw new errors.UnauthorizedError( - requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), - USER_NOT_AUTHORIZED_ERROR.CODE, - USER_NOT_AUTHORIZED_ERROR.PARAM, + if (volunteerMembership.status != "invited") { + // Check if the user is authorized to update the volunteer membership + const isAdminOrSuperAdmin = await adminCheck( + currentUser._id, + event.organization, + false, + ); + const isEventAdmin = event.admins.some( + (admin) => admin.toString() == currentUser._id.toString(), ); + let isGroupLeader = false; + if (volunteerMembership.group != undefined) { + // check if current user is group leader + const group = (await EventVolunteerGroup.findById( + volunteerMembership.group, + ).lean()) as InterfaceEventVolunteerGroup; + isGroupLeader = group.leader.toString() == currentUser._id.toString(); + } + + // If the user is not an admin or super admin, event admin, or group leader, throw an error + if (!isAdminOrSuperAdmin && !isEventAdmin && !isGroupLeader) { + throw new errors.UnauthorizedError( + requestContext.translate(USER_NOT_AUTHORIZED_ERROR.MESSAGE), + USER_NOT_AUTHORIZED_ERROR.CODE, + USER_NOT_AUTHORIZED_ERROR.PARAM, + ); + } } const updatedVolunteerMembership =