Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: access

bautistaaa75e9908997f4
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts
index a3add10f..6666641b 100644
--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts
+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/getChallengeSubmissions.ts
@@ -2,11 +2,14 @@
import { cache } from 'react';
import { prisma } from '@repo/db';
+import { auth } from '@repo/auth/server';
-export const getChallengeSubmissionById = cache((id: string) => {
- return prisma.submission.findFirst({
+export const getChallengeSubmissionById = cache(async (id: string) => {
+ const session = await auth();
+ return prisma.submission.findFirstOrThrow({
where: {
id: Number(id),
+ userId: session?.user?.id || '',
},
include: {
challenge: {
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx
index cb269627..40ff359b 100644
--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx
+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx
@@ -28,7 +28,7 @@ export default async function SubmissionPage({ params: { slug } }: Props) {
const submissions = await withUnstableCache({
fn: getChallengeSubmissions,
- args: [session?.user?.id ?? '', slug],
+ args: [slug],
keys: ['all-challenge-submissions'],
tags: [createChallengeSubmissionCacheKey(slug)],
});
@@ -41,13 +41,15 @@ export default async function SubmissionPage({ params: { slug } }: Props) {
}
export type ChallengeSubmissions = NonNullable<Awaited<ReturnType<typeof getChallengeSubmissions>>>;
-const getChallengeSubmissions = cache(async (userId: string, slug: string) => {
+const getChallengeSubmissions = cache(async (slug: string) => {
+ const session = await auth();
+
const challenge = await prisma.challenge.findFirstOrThrow({
where: { slug },
select: { id: true },
});
return prisma.submission.findMany({
- where: { challengeId: challenge.id, userId },
+ where: { challengeId: challenge.id, userId: session?.user?.id || '' },
orderBy: [
{
createdAt: 'desc',