Skip to content

Commit

Permalink
Add inputs.ts in countlint exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDsza committed Nov 1, 2024
1 parent 2bdeb0b commit 028d2dd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 26 additions & 24 deletions src/resolvers/Mutation/updateVolunteerMembership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 028d2dd

Please sign in to comment.