refactor: enum voor account types
This commit is contained in:
parent
f9fc19d8a6
commit
fc0d3b5c84
20 changed files with 77 additions and 5870 deletions
|
@ -2,6 +2,7 @@ import { authorize } from './auth-checks.js';
|
|||
import { fetchClass } from '../../../services/classes.js';
|
||||
import { fetchAllGroups } from '../../../services/groups.js';
|
||||
import { mapToUsername } from '../../../interfaces/user.js';
|
||||
import {AccountType} from "@dwengo-1/common/util/account-types";
|
||||
|
||||
/**
|
||||
* Expects the path to contain the path parameters 'classId' and 'id' (meaning the ID of the assignment).
|
||||
|
@ -11,7 +12,7 @@ import { mapToUsername } from '../../../interfaces/user.js';
|
|||
*/
|
||||
export const onlyAllowIfHasAccessToAssignment = authorize(async (auth, req) => {
|
||||
const { classid: classId, id: assignmentId } = req.params as { classid: string; id: number };
|
||||
if (auth.accountType === 'teacher') {
|
||||
if (auth.accountType === AccountType.Teacher) {
|
||||
const clazz = await fetchClass(classId);
|
||||
return clazz.teachers.map(mapToUsername).includes(auth.username);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue