fix: fixed linter errors
This commit is contained in:
parent
faa2f58145
commit
7f670030a7
13 changed files with 23 additions and 28 deletions
|
@ -1,5 +1,4 @@
|
|||
import {authorize} from "./auth-checks";
|
||||
import {fetchAssignment} from "../../../services/assignments";
|
||||
import {fetchClass} from "../../../services/classes";
|
||||
import {fetchAllGroups} from "../../../services/groups";
|
||||
import {mapToUsername} from "../../../interfaces/user";
|
||||
|
@ -16,9 +15,9 @@ export const onlyAllowIfHasAccessToAssignment = authorize(
|
|||
if (auth.accountType === "teacher") {
|
||||
const clazz = await fetchClass(classId);
|
||||
return clazz.teachers.map(mapToUsername).includes(auth.username);
|
||||
} else {
|
||||
}
|
||||
const groups = await fetchAllGroups(classId, assignmentId);
|
||||
return groups.some(group => group.members.map((member) => member.username).includes(auth.username) );
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {authorize} from "./auth-checks";
|
||||
import {AuthenticationInfo} from "../authentication-info";
|
||||
import {AuthenticatedRequest} from "../authenticated-request";
|
||||
import {fetchClass, getClass} from "../../../services/classes";
|
||||
import {fetchClass} from "../../../services/classes";
|
||||
import {mapToUsername} from "../../../interfaces/user";
|
||||
|
||||
async function teaches(teacherUsername: string, classId: string): Promise<boolean> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {authorize} from "./auth-checks";
|
||||
import {fetchClass, getClass} from "../../../services/classes";
|
||||
import {fetchGroup, getGroup} from "../../../services/groups";
|
||||
import {fetchClass} from "../../../services/classes";
|
||||
import {fetchGroup} from "../../../services/groups";
|
||||
import {mapToUsername} from "../../../interfaces/user";
|
||||
|
||||
/**
|
||||
|
@ -17,9 +17,9 @@ export const onlyAllowIfHasAccessToGroup = authorize(
|
|||
if (auth.accountType === "teacher") {
|
||||
const clazz = await fetchClass(classId);
|
||||
return clazz.teachers.map(mapToUsername).includes(auth.username);
|
||||
} else { // user is student
|
||||
} // User is student
|
||||
const group = await fetchGroup(classId, assignmentId, groupId);
|
||||
return group.members.map(mapToUsername).includes(auth.username);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {authorize} from "./auth-checks";
|
||||
import {AuthenticationInfo} from "../authentication-info";
|
||||
import {AuthenticatedRequest} from "../authenticated-request";
|
||||
import {fetchGroup, getGroup} from "../../../services/groups";
|
||||
|
||||
/**
|
||||
* Only allows requests whose learning path personalization query parameters ('forGroup' / 'assignmentNo' / 'classId')
|
||||
|
@ -15,10 +14,10 @@ export const onlyAllowPersonalizationForOwnGroup = authorize(
|
|||
const {forGroup, assignmentNo, classId} = req.params;
|
||||
if (auth.accountType === "student" && forGroup && assignmentNo && classId) {
|
||||
// TODO: groupNumber?
|
||||
// const group = await fetchGroup(Number(classId), Number(assignmentNo), )
|
||||
// Const group = await fetchGroup(Number(classId), Number(assignmentNo), )
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ export const onlyAllowAuthorRequest = authorize(
|
|||
|
||||
const question = await fetchQuestion(questionId);
|
||||
|
||||
return question.author.username == auth.username;
|
||||
return question.author.username === auth.username;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -44,7 +44,7 @@ export const onlyAllowAuthorRequestAnswer = authorize(
|
|||
const sequenceNumber = Number(seqAnswer) || FALLBACK_SEQ_NUM;
|
||||
const answer = await fetchAnswer(questionId, sequenceNumber);
|
||||
|
||||
return answer.author.username == auth.username;
|
||||
return answer.author.username === auth.username;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -65,8 +65,8 @@ export const onlyAllowIfHasAccessToQuestion = authorize(
|
|||
if (auth.accountType === "teacher") {
|
||||
const cls = group.assignment.within; // TODO check if contains full objects
|
||||
return cls.teachers.map(mapToUsername).includes(auth.username);
|
||||
} else { // user is student
|
||||
} // User is student
|
||||
return group.members.map(mapToUsername).includes(auth.username);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
|
|
@ -14,10 +14,10 @@ export const onlyAllowSender = authorize(
|
|||
|
||||
export const onlyAllowSenderBody = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) =>
|
||||
req.body.sender === auth.username
|
||||
(req.body as { sender: string }).sender === auth.username
|
||||
);
|
||||
|
||||
export const onlyAllowReceiverBody = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) =>
|
||||
req.body.receiver === auth.username
|
||||
(req.body as { receiver: string }).receiver === auth.username
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue