16 lines
749 B
TypeScript
16 lines
749 B
TypeScript
import { Language } from '@dwengo-1/common/util/language';
|
|
import learningObjectService from '../../../services/learning-objects/learning-object-service.js';
|
|
import { AuthenticatedRequest } from '../authenticated-request.js';
|
|
import { AuthenticationInfo } from '../authentication-info.js';
|
|
import { authorize } from './auth-checks.js';
|
|
|
|
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 admins.includes(auth.username);
|
|
});
|