fix: req.query ipv req.params bij het authorizeren op root endpoint van submissions

This commit is contained in:
Adriaan Jacquet 2025-05-18 15:52:47 +02:00
parent 6d62d8f586
commit 705bce75e9

View file

@ -31,15 +31,15 @@ export const onlyAllowIfHasAccessToSubmission = authorize(async (auth: Authentic
}); });
export const onlyAllowIfHasAccessToSubmissionFromParams = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => { export const onlyAllowIfHasAccessToSubmissionFromParams = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => {
const { classId, assignmentId, groupId } = req.params; const { classId, assignmentId, groupId } = req.query;
requireFields({ classId, assignmentId, groupId }); requireFields({ classId, assignmentId, groupId });
if (auth.accountType === AccountType.Teacher) { if (auth.accountType === AccountType.Teacher) {
const cls = await fetchClass(classId); const cls = await fetchClass(classId as string);
return cls.teachers.map(mapToUsername).includes(auth.username); return cls.teachers.map(mapToUsername).includes(auth.username);
} }
const group = await fetchGroup(classId, +assignmentId, +groupId); const group = await fetchGroup(classId as string, +(assignmentId as string), +(groupId as string));
return group.members.map(mapToUsername).includes(auth.username); return group.members.map(mapToUsername).includes(auth.username);
}); });