1818import io .github .Hattinger04 .user .model .UserService ;
1919
2020@ RestController
21- @ RequestMapping ("/teacher " )
21+ @ RequestMapping ("/USER " )
2222public class CourseController {
2323
2424 @ Autowired
@@ -29,14 +29,16 @@ public class CourseController {
2929 private RestServices restServices ;
3030
3131
32+ // TODO: change hasAuthority('USER') to smth with teacher / student check
33+
3234 /**
3335 * Get all students in Course from database
3436 * Needs Course name
3537 *
3638 * @param json
3739 * @return
3840 */
39- @ PreAuthorize ("hasAuthority('TEACHER ')" )
41+ @ PreAuthorize ("hasAuthority('USER ')" )
4042 @ PostMapping ("/getAllStudents" )
4143 @ ResponseBody
4244 public ResponseEntity <?> getAllStudents () {
@@ -50,12 +52,11 @@ public ResponseEntity<?> getAllStudents() {
5052 * @param json
5153 * @return
5254 */
53- @ PreAuthorize ("hasAuthority('TEACHER ')" )
55+ @ PreAuthorize ("hasAuthority('USER ')" )
5456 @ PutMapping ("/createCourse" )
5557 @ ResponseBody
5658 public ResponseEntity <?> createCourse (@ RequestBody String json ) {
57- Course course = (Course ) restServices .deserialize (Course .class , json );
58- // courseService.createCourse(course);
59+ // courseService.createCourse((Course) restServices.deserialize(Course.class, json););
5960 return new ResponseEntity <>(HttpStatus .OK );
6061 }
6162
@@ -66,7 +67,7 @@ public ResponseEntity<?> createCourse(@RequestBody String json) {
6667 * @param json
6768 * @return
6869 */
69- @ PreAuthorize ("hasAuthority('TEACHER ')" )
70+ @ PreAuthorize ("hasAuthority('USER ')" )
7071 @ DeleteMapping ("/deleteCourse" )
7172 @ ResponseBody
7273 public ResponseEntity <?> deleteCourse (@ RequestBody String json ) {
@@ -81,7 +82,7 @@ public ResponseEntity<?> deleteCourse(@RequestBody String json) {
8182 * @param json
8283 * @return
8384 */
84- @ PreAuthorize ("hasAuthority('TEACHER ')" )
85+ @ PreAuthorize ("hasAuthority('USER ')" )
8586 @ PostMapping ("/addStudentCourse" )
8687 @ ResponseBody
8788 public ResponseEntity <?> addStudentCourse (@ RequestBody String json ) {
@@ -96,7 +97,7 @@ public ResponseEntity<?> addStudentCourse(@RequestBody String json) {
9697 * @param json
9798 * @return
9899 */
99- @ PreAuthorize ("hasAuthority('TEACHER ')" )
100+ @ PreAuthorize ("hasAuthority('USER ')" )
100101 @ DeleteMapping ("/removeStudentCourse" )
101102 @ ResponseBody
102103 public ResponseEntity <?> removeStudentCourse (@ RequestBody String json ) {
@@ -111,7 +112,7 @@ public ResponseEntity<?> removeStudentCourse(@RequestBody String json) {
111112 * @param json
112113 * @return
113114 */
114- @ PreAuthorize ("hasAuthority('TEACHER ')" )
115+ @ PreAuthorize ("hasAuthority('USER ')" )
115116 @ PutMapping ("/createExercise" )
116117 @ ResponseBody
117118 public ResponseEntity <?> createExercise (@ RequestBody String json ) {
@@ -126,7 +127,7 @@ public ResponseEntity<?> createExercise(@RequestBody String json) {
126127 * @param json
127128 * @return
128129 */
129- @ PreAuthorize ("hasAuthority('TEACHER ')" )
130+ @ PreAuthorize ("hasAuthority('USER ')" )
130131 @ PostMapping ("/patchExercise" )
131132 @ ResponseBody
132133 public ResponseEntity <?> patchExercise (@ RequestBody String json ) {
@@ -141,7 +142,7 @@ public ResponseEntity<?> patchExercise(@RequestBody String json) {
141142 * @param json
142143 * @return
143144 */
144- @ PreAuthorize ("hasAuthority('TEACHER ')" )
145+ @ PreAuthorize ("hasAuthority('USER ')" )
145146 @ PutMapping ("/deleteExercise" )
146147 @ ResponseBody
147148 public ResponseEntity <?> deleteExercise (@ RequestBody String json ) {
@@ -156,7 +157,7 @@ public ResponseEntity<?> deleteExercise(@RequestBody String json) {
156157 * @param json
157158 * @return
158159 */
159- @ PreAuthorize ("hasAuthority('TEACHER ')" )
160+ @ PreAuthorize ("hasAuthority('USER ')" )
160161 @ PostMapping ("/rateExercise" )
161162 @ ResponseBody
162163 public ResponseEntity <?> rateExercise (@ RequestBody String json ) {
0 commit comments