style: fix linting issues met Prettier
This commit is contained in:
parent
7f670030a7
commit
0c47546814
30 changed files with 233 additions and 262 deletions
|
@ -1,7 +1,7 @@
|
|||
import {authorize} from "./auth-checks";
|
||||
import {fetchClass} from "../../../services/classes";
|
||||
import {fetchGroup} from "../../../services/groups";
|
||||
import {mapToUsername} from "../../../interfaces/user";
|
||||
import { authorize } from './auth-checks';
|
||||
import { fetchClass } from '../../../services/classes';
|
||||
import { fetchGroup } from '../../../services/groups';
|
||||
import { mapToUsername } from '../../../interfaces/user';
|
||||
|
||||
/**
|
||||
* Expects the path to contain the path parameters 'classid', 'assignmentid' and 'groupid'.
|
||||
|
@ -9,17 +9,17 @@ import {mapToUsername} from "../../../interfaces/user";
|
|||
* - either teachers of the class the assignment for the group was posted in,
|
||||
* - or students in the group
|
||||
*/
|
||||
export const onlyAllowIfHasAccessToGroup = authorize(
|
||||
async (auth, req) => {
|
||||
const { classid: classId, assignmentid: assignmentId, groupid: groupId } =
|
||||
req.params as { classid: string, assignmentid: number, groupid: number };
|
||||
export const onlyAllowIfHasAccessToGroup = authorize(async (auth, req) => {
|
||||
const {
|
||||
classid: classId,
|
||||
assignmentid: assignmentId,
|
||||
groupid: groupId,
|
||||
} = req.params as { classid: string; assignmentid: number; groupid: number };
|
||||
|
||||
if (auth.accountType === "teacher") {
|
||||
const clazz = await fetchClass(classId);
|
||||
return clazz.teachers.map(mapToUsername).includes(auth.username);
|
||||
} // User is student
|
||||
const group = await fetchGroup(classId, assignmentId, groupId);
|
||||
return group.members.map(mapToUsername).includes(auth.username);
|
||||
|
||||
}
|
||||
);
|
||||
if (auth.accountType === 'teacher') {
|
||||
const clazz = await fetchClass(classId);
|
||||
return clazz.teachers.map(mapToUsername).includes(auth.username);
|
||||
} // User is student
|
||||
const group = await fetchGroup(classId, assignmentId, groupId);
|
||||
return group.members.map(mapToUsername).includes(auth.username);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue