fix(backend): Bugs omtrent leerpad-endpoints opgelost
This commit is contained in:
parent
6929288554
commit
1a768fedcc
6 changed files with 12 additions and 12 deletions
|
@ -12,7 +12,7 @@ export class LearningObjectRepository extends DwengoEntityRepository<LearningObj
|
|||
version: identifier.version,
|
||||
},
|
||||
{
|
||||
populate: ['keywords'],
|
||||
populate: ['keywords', 'admins'],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -35,9 +35,7 @@ export class LearningPathRepository extends DwengoEntityRepository<LearningPath>
|
|||
return this.findAll({
|
||||
where: {
|
||||
admins: {
|
||||
$contains: {
|
||||
username: adminUsername
|
||||
}
|
||||
username: adminUsername
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
ArrayType,
|
||||
Cascade,
|
||||
Collection,
|
||||
Embedded,
|
||||
Entity,
|
||||
|
@ -93,6 +94,7 @@ export class LearningObject {
|
|||
@OneToMany({
|
||||
entity: () => Attachment,
|
||||
mappedBy: 'learningObject',
|
||||
cascade: [Cascade.ALL]
|
||||
})
|
||||
attachments: Collection<Attachment> = new Collection<Attachment>(this);
|
||||
|
||||
|
|
|
@ -12,5 +12,5 @@ export const onlyAdminsForLearningObject = authorize(async (auth: Authentication
|
|||
language: language as Language,
|
||||
version: parseInt(version as string)
|
||||
});
|
||||
return auth.username in admins;
|
||||
return admins.includes(auth.username);
|
||||
});
|
||||
|
|
|
@ -3,10 +3,10 @@ import { authorize } from "../auth";
|
|||
import { AuthenticatedRequest } from "../authenticated-request";
|
||||
import { AuthenticationInfo } from "../authentication-info";
|
||||
|
||||
export const onlyAdminsForLearningPath = authorize((auth: AuthenticationInfo, req: AuthenticatedRequest) => {
|
||||
const adminsForLearningPath = learningPathService.getAdmins({
|
||||
export const onlyAdminsForLearningPath = authorize(async (auth: AuthenticationInfo, req: AuthenticatedRequest) => {
|
||||
const adminsForLearningPath = await learningPathService.getAdmins({
|
||||
hruid: req.body.hruid,
|
||||
language: req.body.language
|
||||
});
|
||||
return adminsForLearningPath && auth.username in adminsForLearningPath;
|
||||
return adminsForLearningPath && adminsForLearningPath.includes(auth.username);
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ export async function processLearningObjectZip(filePath: string): Promise<Learni
|
|||
try {
|
||||
zip = await unzipper.Open.file(filePath);
|
||||
} catch(_: unknown) {
|
||||
throw new BadRequestException("invalid_zip");
|
||||
throw new BadRequestException("invalidZip");
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ export async function processLearningObjectZip(filePath: string): Promise<Learni
|
|||
let content: Buffer | undefined = undefined;
|
||||
|
||||
if (zip.files.length === 0) {
|
||||
throw new BadRequestException("empty_zip")
|
||||
throw new BadRequestException("emptyZip")
|
||||
}
|
||||
|
||||
await Promise.all(
|
||||
|
@ -48,10 +48,10 @@ export async function processLearningObjectZip(filePath: string): Promise<Learni
|
|||
);
|
||||
|
||||
if (!metadata) {
|
||||
throw new BadRequestException("missing_metadata");
|
||||
throw new BadRequestException("missingMetadata");
|
||||
}
|
||||
if (!content) {
|
||||
throw new BadRequestException("missing_index");
|
||||
throw new BadRequestException("missingIndex");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue