@@ -63,7 +63,8 @@ export class CoursesController {
6363 * Get enrolled courses for the current user (My Learning)
6464 */
6565 @Get ( 'enrolled' )
66- @UseGuards ( JwtAuthGuard )
66+ @UseGuards ( JwtAuthGuard , RolesGuard )
67+ @Roles ( UserRole . STUDENT , UserRole . INSTRUCTOR )
6768 getEnrolledCourses (
6869 @CurrentUser ( ) user : User ,
6970 @Query ( 'archived' ) archived ?: string ,
@@ -77,7 +78,7 @@ export class CoursesController {
7778
7879 @Get ( 'instructor/my-courses' )
7980 @UseGuards ( JwtAuthGuard , RolesGuard )
80- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
81+ @Roles ( UserRole . INSTRUCTOR )
8182 getMyCourses ( @CurrentUser ( ) user : User ) : Promise < Course [ ] > {
8283 return this . coursesService . findInstructorCourses ( user . id ) ;
8384 }
@@ -121,7 +122,8 @@ export class CoursesController {
121122 }
122123
123124 @Post ( ':id/enroll' )
124- @UseGuards ( JwtAuthGuard )
125+ @UseGuards ( JwtAuthGuard , RolesGuard )
126+ @Roles ( UserRole . STUDENT , UserRole . INSTRUCTOR )
125127 async enroll (
126128 @Param ( 'id' ) id : string ,
127129 @CurrentUser ( ) user : User ,
@@ -138,13 +140,15 @@ export class CoursesController {
138140 isEnrolled : boolean ;
139141 isInstructor : boolean ;
140142 isAdmin : boolean ;
143+ hasAccess : boolean ;
141144 progress : Enrollment | null ;
142145 } > {
143146 const accessInfo = await this . coursesService . checkCourseAccess ( user , id ) ;
144147 return {
145148 isEnrolled : accessInfo . isEnrolled ,
146149 isInstructor : accessInfo . isInstructor ,
147150 isAdmin : accessInfo . isAdmin ,
151+ hasAccess : accessInfo . hasAccess ,
148152 progress : accessInfo . enrollment ,
149153 } ;
150154 }
@@ -168,7 +172,8 @@ export class CoursesController {
168172 }
169173
170174 @Post ( ':id/lessons/:lessonId/complete' )
171- @UseGuards ( JwtAuthGuard )
175+ @UseGuards ( JwtAuthGuard , RolesGuard )
176+ @Roles ( UserRole . STUDENT , UserRole . INSTRUCTOR )
172177 async completeLesson (
173178 @Param ( 'id' ) courseId : string ,
174179 @Param ( 'lessonId' ) lessonId : string ,
@@ -181,7 +186,8 @@ export class CoursesController {
181186 * Archive a course (hide from main list, preserve progress)
182187 */
183188 @Patch ( ':id/archive' )
184- @UseGuards ( JwtAuthGuard )
189+ @UseGuards ( JwtAuthGuard , RolesGuard )
190+ @Roles ( UserRole . STUDENT , UserRole . INSTRUCTOR )
185191 async archiveCourse (
186192 @Param ( 'id' ) id : string ,
187193 @CurrentUser ( ) user : User ,
@@ -194,7 +200,8 @@ export class CoursesController {
194200 * Unarchive a course (restore to main list)
195201 */
196202 @Patch ( ':id/unarchive' )
197- @UseGuards ( JwtAuthGuard )
203+ @UseGuards ( JwtAuthGuard , RolesGuard )
204+ @Roles ( UserRole . STUDENT , UserRole . INSTRUCTOR )
198205 async unarchiveCourse (
199206 @Param ( 'id' ) id : string ,
200207 @CurrentUser ( ) user : User ,
@@ -205,7 +212,7 @@ export class CoursesController {
205212
206213 @Post ( )
207214 @UseGuards ( JwtAuthGuard , RolesGuard )
208- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
215+ @Roles ( UserRole . INSTRUCTOR )
209216 create (
210217 @Body ( ) createCourseDto : CreateCourseDto ,
211218 @CurrentUser ( ) user : User ,
@@ -215,7 +222,7 @@ export class CoursesController {
215222
216223 @Patch ( ':id' )
217224 @UseGuards ( JwtAuthGuard , RolesGuard )
218- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
225+ @Roles ( UserRole . INSTRUCTOR )
219226 update (
220227 @Param ( 'id' ) id : string ,
221228 @Body ( ) updateCourseDto : UpdateCourseDto ,
@@ -226,7 +233,7 @@ export class CoursesController {
226233
227234 @Delete ( ':id' )
228235 @UseGuards ( JwtAuthGuard , RolesGuard )
229- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
236+ @Roles ( UserRole . INSTRUCTOR )
230237 remove ( @Param ( 'id' ) id : string , @CurrentUser ( ) user : User ) : Promise < void > {
231238 return this . coursesService . remove ( id , user . id ) ;
232239 }
@@ -235,7 +242,7 @@ export class CoursesController {
235242
236243 @Post ( ':id/sections' )
237244 @UseGuards ( JwtAuthGuard , RolesGuard )
238- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
245+ @Roles ( UserRole . INSTRUCTOR )
239246 createSection (
240247 @Param ( 'id' ) courseId : string ,
241248 @Body ( ) dto : CreateSectionDto ,
@@ -246,7 +253,7 @@ export class CoursesController {
246253
247254 @Delete ( 'sections/:sectionId' )
248255 @UseGuards ( JwtAuthGuard , RolesGuard )
249- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
256+ @Roles ( UserRole . INSTRUCTOR )
250257 deleteSection (
251258 @Param ( 'sectionId' ) sectionId : string ,
252259 @CurrentUser ( ) user : User ,
@@ -256,7 +263,7 @@ export class CoursesController {
256263
257264 @Post ( 'sections/:sectionId/lessons' )
258265 @UseGuards ( JwtAuthGuard , RolesGuard )
259- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
266+ @Roles ( UserRole . INSTRUCTOR )
260267 createLesson (
261268 @Param ( 'sectionId' ) sectionId : string ,
262269 @Body ( ) dto : CreateLessonDto ,
@@ -267,7 +274,7 @@ export class CoursesController {
267274
268275 @Patch ( 'lessons/:lessonId' )
269276 @UseGuards ( JwtAuthGuard , RolesGuard )
270- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
277+ @Roles ( UserRole . INSTRUCTOR )
271278 updateLesson (
272279 @Param ( 'lessonId' ) lessonId : string ,
273280 @Body ( ) dto : UpdateLessonDto ,
@@ -278,7 +285,7 @@ export class CoursesController {
278285
279286 @Delete ( 'lessons/:lessonId' )
280287 @UseGuards ( JwtAuthGuard , RolesGuard )
281- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
288+ @Roles ( UserRole . INSTRUCTOR )
282289 deleteLesson (
283290 @Param ( 'lessonId' ) lessonId : string ,
284291 @CurrentUser ( ) user : User ,
@@ -288,7 +295,7 @@ export class CoursesController {
288295
289296 @Post ( ':id/sections/reorder' )
290297 @UseGuards ( JwtAuthGuard , RolesGuard )
291- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
298+ @Roles ( UserRole . INSTRUCTOR )
292299 reorderSections (
293300 @Param ( 'id' ) courseId : string ,
294301 @Body ( 'sectionIds' ) sectionIds : string [ ] ,
@@ -299,7 +306,7 @@ export class CoursesController {
299306
300307 @Post ( 'sections/:sectionId/lessons/reorder' )
301308 @UseGuards ( JwtAuthGuard , RolesGuard )
302- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
309+ @Roles ( UserRole . INSTRUCTOR )
303310 reorderLessons (
304311 @Param ( 'sectionId' ) sectionId : string ,
305312 @Body ( 'lessonIds' ) lessonIds : string [ ] ,
@@ -323,7 +330,7 @@ export class CoursesController {
323330
324331 @Post ( ':id/sections/:sectionId/generate-quiz-preview' )
325332 @UseGuards ( JwtAuthGuard , RolesGuard )
326- @Roles ( UserRole . INSTRUCTOR , UserRole . ADMIN )
333+ @Roles ( UserRole . INSTRUCTOR )
327334 async generateQuiz (
328335 @Body ( ) dto : GenerateQuizPreviewDto ,
329336 ) : Promise < { title : string ; questions : GeneratedQuestion [ ] } > {
0 commit comments