File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
src/main/java/net/hackyourfuture/coursehub Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3737 .permitAll ()
3838 .requestMatchers (HttpMethod .OPTIONS , "/courses" )
3939 .permitAll ()
40+ .requestMatchers ("/students/**" )
41+ .hasRole ("student" )
4042 .anyRequest ()
4143 .authenticated ())
4244 .build ();
Original file line number Diff line number Diff line change 11package net .hackyourfuture .coursehub .web ;
22
3+ import jakarta .validation .constraints .Positive ;
34import net .hackyourfuture .coursehub .service .CourseService ;
45import net .hackyourfuture .coursehub .web .model .CourseDto ;
56import org .springframework .web .bind .annotation .GetMapping ;
7+ import org .springframework .web .bind .annotation .PathVariable ;
68import org .springframework .web .bind .annotation .RequestMapping ;
79import org .springframework .web .bind .annotation .RestController ;
810
@@ -19,7 +21,7 @@ public StudentController(CourseService courseService) {
1921 }
2022
2123 @ GetMapping ("/{studentId}/courses" )
22- public List <CourseDto > getCoursesForStudent (Integer studentId ) {
24+ public List <CourseDto > getCoursesForStudent (@ PathVariable ( value = "studentId" ) @ Positive Integer studentId ) {
2325 return courseService .getCoursesForStudent (studentId );
2426 }
2527}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ function MyCourses({user}: { user: User | null }) {
1717 credentials : "include" ,
1818 } ) . then ( res => res . json ( ) )
1919 . then ( data => setCourses ( data . courses ) )
20- . catch ( err => console . error ( ' Error fetching courses:' , err ) )
20+ . catch ( err => console . error ( " Error fetching My Courses:" , err ) )
2121 } , [ ] )
2222
2323 return (
@@ -40,7 +40,7 @@ function MyCourses({user}: { user: User | null }) {
4040 < tbody >
4141 { courses . map ( ( course , idx ) => (
4242 < tr
43- key = { course . courseId }
43+ key = { course . id }
4444 className = { `border-t transition ${ idx % 2 === 0 ? 'bg-gray-50' : 'bg-white' } hover:bg-blue-50` }
4545 >
4646 < td className = "px-6 py-4 text-gray-700" > { course . name } </ td >
@@ -59,5 +59,3 @@ function MyCourses({user}: { user: User | null }) {
5959}
6060
6161export default MyCourses
62-
63-
You can’t perform that action at this time.
0 commit comments