Closed OnurhanTALAN closed 5 days ago
The exception stating that "teachers can create assignments only for their assigned classes" cannot be enforced on the front end, as classes for which the teacher does not have permission are not displayed and therefore not available as options. However, there are alternative methods for directly sending requests to the back-end that could potentially bypass this restriction. Consequently, this exception remains relevant and necessary.
Similarly, other states are affected for the same reason; direct interaction with the back end, bypassing the front end, is possible. Therefore, no additional actions are required on the front end. This approach is implemented for security reasons.
in assignmentService , there are multiple reasons that the assignment creation might fail. not all of them can be displayed to the user. For example, if the exceptions "Teachers can create assignments only their assigned classes" and "An assignment with this title already exists for this class" occur, they can be displayed to user. On the other hand, if the others occur,other actions should be taken. How can ı do that ?
@Transactional public Assignment createAssignment(AssignmentRequestDTO dto, Long loggedInUserId) throws AccessDeniedException { AppUser teacher = appUserRepository.findById(loggedInUserId) .orElseThrow(() -> new EntityNotFoundException("Teacher not found")); ClassEntity classEntity = classEntityRepository.findClassEntityByName(dto.getClassName()).orElseThrow( () -> new EntityNotFoundException("Class not found") ); Course course = courseRepository.findCourseByName(dto.getCourseName()).orElseThrow( () -> new EntityNotFoundException("Course not found") );