Skip to content

Commit

Permalink
Merge pull request #235 from krishhh16/main
Browse files Browse the repository at this point in the history
closes #212
  • Loading branch information
hkirat authored Mar 26, 2024
2 parents 919a4b3 + 62d0572 commit c20e36f
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 c20e36f

Please sign in to comment.