style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-04-22 16:04:52 +00:00
parent 7f670030a7
commit 0c47546814
30 changed files with 233 additions and 262 deletions

View file

@ -1,7 +1,7 @@
import {authorize} from "./auth-checks";
import {fetchClass} from "../../../services/classes";
import {fetchAllGroups} from "../../../services/groups";
import {mapToUsername} from "../../../interfaces/user";
import { authorize } from './auth-checks';
import { fetchClass } from '../../../services/classes';
import { fetchAllGroups } from '../../../services/groups';
import { mapToUsername } from '../../../interfaces/user';
/**
* Expects the path to contain the path parameters 'classId' and 'id' (meaning the ID of the assignment).
@ -9,15 +9,12 @@ import {mapToUsername} from "../../../interfaces/user";
* - either teachers of the class the assignment was posted in,
* - or students in a group of the assignment.
*/
export const onlyAllowIfHasAccessToAssignment = authorize(
async (auth, req) => {
const { classid: classId, id: assignmentId } = req.params as { classid: string, id: number };
if (auth.accountType === "teacher") {
const clazz = await fetchClass(classId);
return clazz.teachers.map(mapToUsername).includes(auth.username);
}
const groups = await fetchAllGroups(classId, assignmentId);
return groups.some(group => group.members.map((member) => member.username).includes(auth.username) );
export const onlyAllowIfHasAccessToAssignment = authorize(async (auth, req) => {
const { classid: classId, id: assignmentId } = req.params as { classid: string; id: number };
if (auth.accountType === 'teacher') {
const clazz = await fetchClass(classId);
return clazz.teachers.map(mapToUsername).includes(auth.username);
}
);
const groups = await fetchAllGroups(classId, assignmentId);
return groups.some((group) => group.members.map((member) => member.username).includes(auth.username));
});