Skip to content

Commit

Permalink
closes #212
Browse files Browse the repository at this point in the history
  • Loading branch information
0xzrf committed Mar 17, 2024
1 parent 86274f2 commit 445505c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/app/courses/[...courseId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,27 @@ import { redirect } from 'next/navigation';
import { CourseView } from '@/components/CourseView';
import { QueryParams } from '@/actions/types';

interface PurchaseType {
id: number;
title: string;
imageUrl: string;
description: string;
appxCourseId: number;
openToEveryone: boolean;
slug: string;
discordRoleId: string;
totalVideos?: number;
totalVideosWatched: number;
}

const checkAccess = async (courseId: string) => {
const session = await getServerSession(authOptions);

if (!session?.user) {
return false;
}
const purchases = await getPurchases(session.user.email);
if (purchases.map((p: any) => p.id).includes(Number(courseId))) {
if (purchases.map((p: PurchaseType) => p.id).includes(Number(courseId))) {
return true;
}
return false;
Expand Down

0 comments on commit 445505c

Please sign in to comment.