diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java index ebfa730..c86b46e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CourseController.java @@ -9,6 +9,8 @@ import ovh.herisson.Clyde.Services.CourseService; import ovh.herisson.Clyde.Services.TeacherCourseService; import ovh.herisson.Clyde.Tables.Course; import ovh.herisson.Clyde.Tables.Role; + +import java.util.HashMap; import java.util.Map; @RestController @@ -28,7 +30,7 @@ public class CourseController { } @GetMapping("/course/{id}") - public ResponseEntity getCourse(@RequestHeader("Authorization") String token, @PathVariable long id){ + public ResponseEntity> getCourse(@RequestHeader("Authorization") String token, @PathVariable long id){ if (authServ.getUserFromToken(token) == null) return new UnauthorizedResponse<>(null); @@ -37,7 +39,7 @@ public class CourseController { if (foundCourse == null) return new ResponseEntity<>(HttpStatus.BAD_REQUEST); - return new ResponseEntity<>(foundCourse, HttpStatus.OK); + return new ResponseEntity<>(courseWithoutPassword(foundCourse), HttpStatus.OK); } @@ -85,4 +87,15 @@ public class CourseController { return new ResponseEntity<>(HttpStatus.OK); } + + + + private HashMap courseWithoutPassword(Course course){ + HashMap toReturn = new HashMap<>(); + + toReturn.put("courseId",course.getCourseID()); + toReturn.put("credits",course.getCredits()); + toReturn.put("title", course.getTitle()); + toReturn.put("owner", authServ.userWithoutPassword(course.getOwner())); + } }