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,29 +1,27 @@
|
|||
import { languageMap } from "dwengo-1-common/util/language";
|
||||
import { LearningObjectIdentifier } from "../../../entities/content/learning-object-identifier";
|
||||
import { fetchSubmission } from "../../../services/submissions";
|
||||
import { AuthenticatedRequest } from "../authenticated-request";
|
||||
import { AuthenticationInfo } from "../authentication-info";
|
||||
import { authorize } from "./auth-checks";
|
||||
import { FALLBACK_LANG } from "../../../config";
|
||||
import { mapToUsername } from "../../../interfaces/user";
|
||||
import { languageMap } from 'dwengo-1-common/util/language';
|
||||
import { LearningObjectIdentifier } from '../../../entities/content/learning-object-identifier';
|
||||
import { fetchSubmission } from '../../../services/submissions';
|
||||
import { AuthenticatedRequest } from '../authenticated-request';
|
||||
import { AuthenticationInfo } from '../authentication-info';
|
||||
import { authorize } from './auth-checks';
|
||||
import { FALLBACK_LANG } from '../../../config';
|
||||
import { mapToUsername } from '../../../interfaces/user';
|
||||
|
||||
export const onlyAllowSubmitter = authorize(
|
||||
(auth: AuthenticationInfo, req: AuthenticatedRequest) => (req.body as { submitter: string }).submitter === auth.username
|
||||
);
|
||||
|
||||
export const onlyAllowIfHasAccessToSubmission = authorize(
|
||||
async (auth: AuthenticationInfo, req: AuthenticatedRequest) => {
|
||||
const { hruid: lohruid, id: submissionNumber } = req.params;
|
||||
const { language: lang, version: version } = req.query;
|
||||
export const onlyAllowIfHasAccessToSubmission = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => {
|
||||
const { hruid: lohruid, id: submissionNumber } = req.params;
|
||||
const { language: lang, version: version } = req.query;
|
||||
|
||||
const loId = new LearningObjectIdentifier(lohruid, languageMap[lang as string] ?? FALLBACK_LANG, Number(version))
|
||||
const submission = await fetchSubmission(loId, Number(submissionNumber));
|
||||
const loId = new LearningObjectIdentifier(lohruid, languageMap[lang as string] ?? FALLBACK_LANG, Number(version));
|
||||
const submission = await fetchSubmission(loId, Number(submissionNumber));
|
||||
|
||||
if (auth.accountType === "teacher") {
|
||||
// Dit kan niet werken om dat al deze objecten niet gepopulate zijn.
|
||||
return submission.onBehalfOf.assignment.within.teachers.map(mapToUsername).includes(auth.username);
|
||||
}
|
||||
|
||||
return submission.onBehalfOf.members.map(mapToUsername).includes(auth.username);
|
||||
if (auth.accountType === 'teacher') {
|
||||
// Dit kan niet werken om dat al deze objecten niet gepopulate zijn.
|
||||
return submission.onBehalfOf.assignment.within.teachers.map(mapToUsername).includes(auth.username);
|
||||
}
|
||||
)
|
||||
|
||||
return submission.onBehalfOf.members.map(mapToUsername).includes(auth.username);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue