diff --git a/src/app/actions/analyze.ts b/src/app/actions/analyze.ts index b39356e..f226353 100644 --- a/src/app/actions/analyze.ts +++ b/src/app/actions/analyze.ts @@ -75,8 +75,13 @@ export const getAnalysis = async ( ); } - const analysis = await prisma.codeAnalysis.findUnique({ - where: { submissionId: submissionId }, + const analysis = await prisma.codeAnalysis.findFirst({ + where: { + submissionId, + submission: { + userId: session.user.id, + }, + }, }); if (!analysis) { diff --git a/src/features/problems/detail/components/table.tsx b/src/features/problems/detail/components/table.tsx index ef4ded6..cfc87b2 100644 --- a/src/features/problems/detail/components/table.tsx +++ b/src/features/problems/detail/components/table.tsx @@ -1,4 +1,5 @@ import { cn } from "@/lib/utils"; +import { auth } from "@/lib/auth"; import prisma from "@/lib/prisma"; import { Locale } from "@/generated/client"; import { Label } from "@/components/ui/label"; @@ -22,17 +23,17 @@ export const DetailTable = async ({ submissionId }: DetailTableProps) => { const t = await getTranslations("DetailsPage"); const s = await getTranslations("StatusMessage"); const locale = (await getLocale()) as Locale; - const submission = await prisma.submission.findUnique({ - where: { - id: submissionId, - }, - }); - const judge = await prisma.judge.findUnique({ - where: { submissionId }, - select: { - compileOutput: true, - }, - }); + const session = await auth(); + const userId = session?.user?.id; + + const submission = userId + ? await prisma.submission.findFirst({ + where: { + id: submissionId, + userId, + }, + }) + : null; if (!submission) return ( @@ -41,6 +42,13 @@ export const DetailTable = async ({ submissionId }: DetailTableProps) => { ); + const judge = await prisma.judge.findUnique({ + where: { submissionId }, + select: { + compileOutput: true, + }, + }); + const createdAt = new Date(submission.createdAt); const submittedDisplay = formatSubmissionDate(createdAt, locale); diff --git a/src/features/problems/submission/components/content.tsx b/src/features/problems/submission/components/content.tsx index 28bb51c..5d2791f 100644 --- a/src/features/problems/submission/components/content.tsx +++ b/src/features/problems/submission/components/content.tsx @@ -46,7 +46,7 @@ export const SubmissionContent = async ({ return userId ? (