-
Notifications
You must be signed in to change notification settings - Fork 0
feat: create classrooms #33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Kdocs
| import java.io.* | ||
|
|
||
| @Entity | ||
| @Table(name = "classroom_teachers", uniqueConstraints = [UniqueConstraint(columnNames = ["classroom_id", "teacher_user_id"])]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KDocs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ALA codex code review
| */ | ||
| @Transactional(readOnly = true) | ||
| fun getClassrooms(): List<Classroom> = | ||
| classroomRepository.findAll() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getClassrooms() now returns classroomRepository.findAll(), and the response includes each classroom's joinCode. Because the paired GET /api/v1/classrooms/{id} path also has no membership/ownership check, any authenticated pupil or teacher can enumerate every classroom, inspect rosters/teacher emails, and recover join codes for classes they should not see.
| * @throws ResponseStatusException if the classroom does not exist or if one or more teacher emails cannot be resolved. | ||
| */ | ||
| @Transactional | ||
| fun updateClassroom(command: UpdateClassroomCommand): Classroom { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new mutation paths do not verify that the caller owns the classroom: updateClassroom ignores authenticatedSubject, and approvePupil/removePupil do not even receive a principal. As shipped, any authenticated user who knows a classroom id can rename the class, replace its teacher list, approve pending pupils, or remove pupils from someone else's classroom.
| @@ -18,14 +21,42 @@ import java.util.* | |||
| * | |||
| * @property classroomRepository repository for classroom access | |||
| * @property currentUserResolver shared resolver for the authenticated user and role guard | |||
| * @property userRepository: userRepository repository for user access | |||
| */ | |||
| @Service | |||
| class ClassroomService( | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods call classroom.approvePupil/removePupil, which throw IllegalArgumentException when the pupil is not in the classroom. In practice, a stale or mistyped {pupilId} will now surface as a 500 response instead of a client error, so the new endpoints need to translate that case into a ResponseStatusException (for example 404 or 409).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just a few conflicts
adds classroom creation and some management stuff