From da076f71a117c9710969ae04b645f133790a0c03 Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Mon, 29 Sep 2025 18:09:03 +0530 Subject: [PATCH] fix: when course is unpublished and not coming either, user should not be able to access the course details --- frontend/src/components/CourseCardOverlay.vue | 1 + frontend/src/pages/CourseDetail.vue | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/CourseCardOverlay.vue b/frontend/src/components/CourseCardOverlay.vue index 9f3b87fc..68accaa9 100644 --- a/frontend/src/components/CourseCardOverlay.vue +++ b/frontend/src/components/CourseCardOverlay.vue @@ -169,6 +169,7 @@ { + if (!isInstructor() && !course.data?.published && !course.data?.upcoming) { + router.push({ + name: 'Courses', + }) + } +}) + +const isInstructor = () => { + let user_is_instructor = false + course.data?.instructors.forEach((instructor) => { + if (!user_is_instructor && instructor.name == user.data?.name) { + user_is_instructor = true + } + }) + return user_is_instructor +} + const breadcrumbs = computed(() => { let items = [{ label: 'Courses', route: { name: 'Courses' } }] items.push({