core: bug fixes

This commit is contained in:
undefined committed 2024-01-08 16:45:23 +08:00
1 parent 5369d8d5eb
commit b027505512
2 files changed
+3 -3

No files matched your search

+2 -2
View File
@@ -807,8 +807,8 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
@post('std', Types.Filename)
@post('gen', Types.Filename)
async postGenerateTestdata(domainId: string, std: string, gen: string) {
if (!this.pdoc.data.find((i) => i.name === std)) throw new BadRequestError();
if (!this.pdoc.data.find((i) => i.name === gen)) throw new BadRequestError();
if (!this.pdoc.data?.find((i) => i.name === std)) throw new BadRequestError();
if (!this.pdoc.data?.find((i) => i.name === gen)) throw new BadRequestError();
const rid = await record.add(domainId, this.pdoc.docId, this.user._id, '_', `${gen}\n${std}`, true, {
type: 'generate',
});
+1 -1
View File
@@ -189,7 +189,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
if (this.tdoc.allowViewCode && contest.isDone(this.tdoc)) {
canViewCode ||= tsdoc?.attend;
}
if (!tsdoc?.attend && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
if (!tsdoc?.attend && pdoc && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
} else if (pdoc && !problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
if (!canViewCode) {
rdoc.code = '';