diff --git a/src/app/api/mobile/courses/[courseId]/[collectionId]/[contentId]/route.ts b/src/app/api/mobile/courses/[courseId]/[collectionId]/[contentId]/route.ts index f1b0a5364..47e27e375 100644 --- a/src/app/api/mobile/courses/[courseId]/[collectionId]/[contentId]/route.ts +++ b/src/app/api/mobile/courses/[courseId]/[collectionId]/[contentId]/route.ts @@ -10,7 +10,7 @@ async function checkUserContentAccess(userId: string, contentId: string) { course: { purchasedBy: { some: { - userId: userId, + userId, }, }, }, @@ -21,13 +21,19 @@ async function checkUserContentAccess(userId: string, contentId: string) { return userContent !== null; } -export async function GET(req : NextRequest,{ params }: { params: { contentId: string } }) { +export async function GET( + req: NextRequest, + { params }: { params: { contentId: string } }, +) { try { const { contentId } = params; const user = JSON.parse(req.headers.get('g') || ''); const userContentAccess = await checkUserContentAccess(user.id, contentId); if (!userContentAccess) { - return NextResponse.json({ message: 'User does not have access to this content' }, { status: 403 }); + return NextResponse.json( + { message: 'User does not have access to this content' }, + { status: 403 }, + ); } const contents = await db.content.findUnique({ where: { diff --git a/src/app/api/mobile/courses/[courseId]/[collectionId]/route.ts b/src/app/api/mobile/courses/[courseId]/[collectionId]/route.ts index 5a8deae23..e6a8e715a 100644 --- a/src/app/api/mobile/courses/[courseId]/[collectionId]/route.ts +++ b/src/app/api/mobile/courses/[courseId]/[collectionId]/route.ts @@ -10,10 +10,10 @@ async function checkUserCollectionAccess(userId: string, collectionId: string) { course: { purchasedBy: { some: { - userId: userId, + userId, }, }, - }, + }, }, }, }, @@ -31,11 +31,17 @@ export async function GET( if (!user) { return NextResponse.json({ message: 'User not found' }, { status: 401 }); } - + const { collectionId } = params; - const userHasCollectionAccess = await checkUserCollectionAccess(user.id, collectionId); + const userHasCollectionAccess = await checkUserCollectionAccess( + user.id, + collectionId, + ); if (!userHasCollectionAccess) { - return NextResponse.json({ message: 'User does not have access to this collection' }, { status: 403 }); + return NextResponse.json( + { message: 'User does not have access to this collection' }, + { status: 403 }, + ); } const collectionData = await db.content.findMany({ where: { diff --git a/src/app/api/mobile/courses/[courseId]/route.ts b/src/app/api/mobile/courses/[courseId]/route.ts index ee0e37b53..795f69f27 100644 --- a/src/app/api/mobile/courses/[courseId]/route.ts +++ b/src/app/api/mobile/courses/[courseId]/route.ts @@ -6,7 +6,7 @@ async function checkUserCourseAccess(userId: string, courseId: string) { where: { purchasedBy: { some: { - userId: userId, + userId, }, }, id: parseInt(courseId, 10), @@ -16,7 +16,6 @@ async function checkUserCourseAccess(userId: string, courseId: string) { return userCourse !== null; } - export async function GET( request: NextRequest, { params }: { params: { courseId: string } },