feat(backend): Bescherming van leerobject-manipulatie endpoints.
Ook delete route voor leerobjecten toegevoegd.
This commit is contained in:
parent
a7f90aace3
commit
20c04370b5
4 changed files with 50 additions and 4 deletions
|
@ -0,0 +1,16 @@
|
|||
import { Language } from "@dwengo-1/common/util/language";
|
||||
import learningObjectService from "../../../services/learning-objects/learning-object-service";
|
||||
import { authorize } from "../auth";
|
||||
import { AuthenticatedRequest } from "../authenticated-request";
|
||||
import { AuthenticationInfo } from "../authentication-info";
|
||||
|
||||
export const onlyAdminsForLearningObject = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => {
|
||||
const { hruid } = req.params;
|
||||
const { version, language } = req.query;
|
||||
const admins = await learningObjectService.getAdmins({
|
||||
hruid,
|
||||
language: language as Language,
|
||||
version: parseInt(version as string)
|
||||
});
|
||||
return auth.username in admins;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue