added security to the post of course and GET /courses
This commit is contained in:
@@ -17,6 +17,8 @@ public class CourseService {
|
||||
}
|
||||
|
||||
public Course save(Course course){
|
||||
if (course.getOwner().getRole() != Role.Teacher)
|
||||
return null;
|
||||
return courseRepo.save(course);
|
||||
}
|
||||
|
||||
@@ -24,6 +26,11 @@ public class CourseService {
|
||||
return courseRepo.findById(id);
|
||||
}
|
||||
|
||||
|
||||
public Iterable<Course> findAll() {
|
||||
return courseRepo.findAll();
|
||||
}
|
||||
|
||||
public boolean modifyData(long id, Map<String, Object> updates, Role role) {
|
||||
Course target = courseRepo.findById(id);
|
||||
|
||||
@@ -62,4 +69,5 @@ public class CourseService {
|
||||
courseRepo.save(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user