Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): update permission checks for course group information #1698

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ class GroupController{
val user = authService.authorize(req, res)
val someCourseRole = courseRegistrationService.getParticipants(cid).find(_.user.id == user.id).map(_.role)
(user.globalRole, someCourseRole) match {
case (GlobalRole.ADMIN | GlobalRole.MODERATOR, _) | (_, Some(CourseRole.DOCENT)) =>
val groupList = groupService.getAll(cid, ignoreHidden = false)
groupList
case _ => throw new ForbiddenException()
case (GlobalRole.ADMIN | GlobalRole.MODERATOR, _) | (_, Some(CourseRole.DOCENT)) => groupService.getAll(cid, ignoreHidden = false)
case _ => groupService.getAll(cid)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,8 @@ class GroupRegistrationController {
@GetMapping(value = Array("/courses/{cid}/groups/{gid}/participants"))
@ResponseBody
def getMembers(@PathVariable("cid") cid: Integer, @PathVariable("gid") gid: Int, req: HttpServletRequest, res: HttpServletResponse): List[Participant] = {
val user = authService.authorize(req, res)
val hasGlobalPrivileges = user.hasRole(GlobalRole.ADMIN, GlobalRole.MODERATOR)
val hasCoursePrivileges = courseRegistrationService.getCoursePrivileges(user.id).getOrElse(cid, CourseRole.STUDENT) == CourseRole.DOCENT
if (hasGlobalPrivileges || hasCoursePrivileges) {
groupRegistrationService.getMembers(cid, gid)
} else {
throw new ForbiddenException()
}
authService.authorize(req, res)
groupRegistrationService.getMembers(cid, gid)
}

/**
Expand Down
Loading