diff --git a/apps/backend/apps/client/src/submission/submission.controller.ts b/apps/backend/apps/client/src/submission/submission.controller.ts index ec3a945ce1..9e42f3a6f5 100644 --- a/apps/backend/apps/client/src/submission/submission.controller.ts +++ b/apps/backend/apps/client/src/submission/submission.controller.ts @@ -172,7 +172,6 @@ export class ContestSubmissionController { problemId, contestId, userId: req.user.id, - isAdmin: req.user.isAdmin(), groupId }) } catch (error) { diff --git a/apps/backend/apps/client/src/submission/submission.service.spec.ts b/apps/backend/apps/client/src/submission/submission.service.spec.ts index 5c6a97da81..68800869d9 100644 --- a/apps/backend/apps/client/src/submission/submission.service.spec.ts +++ b/apps/backend/apps/client/src/submission/submission.service.spec.ts @@ -422,8 +422,7 @@ describe('SubmissionService', () => { await service.getContestSubmissions({ problemId: problems[0].id, contestId: 1, - userId: submissions[0].userId, - isAdmin: false + userId: submissions[0].userId }) ) }) @@ -437,8 +436,7 @@ describe('SubmissionService', () => { service.getContestSubmissions({ problemId: problems[0].id, contestId: 1, - userId: submissions[0].userId, - isAdmin: false + userId: submissions[0].userId }) ).to.be.rejectedWith(NotFoundException) }) @@ -453,8 +451,7 @@ describe('SubmissionService', () => { service.getContestSubmissions({ problemId: problems[0].id, contestId: 1, - userId: submissions[0].userId, - isAdmin: false + userId: submissions[0].userId }) ).to.be.rejectedWith(NotFoundException) }) diff --git a/apps/backend/apps/client/src/submission/submission.service.ts b/apps/backend/apps/client/src/submission/submission.service.ts index c241fabc8f..0cf2fd3dd1 100644 --- a/apps/backend/apps/client/src/submission/submission.service.ts +++ b/apps/backend/apps/client/src/submission/submission.service.ts @@ -628,7 +628,6 @@ export class SubmissionService implements OnModuleInit { problemId, contestId, userId, - isAdmin, groupId = OPEN_SPACE_ID, cursor = null, take = 10 @@ -636,22 +635,31 @@ export class SubmissionService implements OnModuleInit { problemId: number contestId: number userId: number - isAdmin: boolean groupId?: number cursor?: number | null take?: number }): Promise[]> { const paginator = this.prisma.getPaginator(cursor) - await this.prisma.contestRecord.findUniqueOrThrow({ + const isAdmin = await this.prisma.user.findFirst({ where: { - // eslint-disable-next-line @typescript-eslint/naming-convention - contestId_userId: { - contestId, - userId - } + id: userId, + role: 'Admin' } }) + + if (!isAdmin) { + await this.prisma.contestRecord.findUniqueOrThrow({ + where: { + // eslint-disable-next-line @typescript-eslint/naming-convention + contestId_userId: { + contestId, + userId + } + } + }) + } + await this.prisma.contestProblem.findFirstOrThrow({ where: { problem: {