@@ -228,6 +228,7 @@ class RoleService(
228228 searchNames.forEach {
229229 cacheManager.getCache(" RoleService.findUserByAllCriteria" )?.evict(it);
230230 cacheManager.getCache(" RoleService.getRegistrationIDCandidates" )?.evict(it);
231+ // TODO: probably should also evict isSupervisor here, but it's an edge case
231232 }
232233 // check all courses if the user has been registered under one of the possible identifiers
233234 val roles = proxy.getUserRoles(searchNames)
@@ -250,6 +251,7 @@ class RoleService(
250251 }
251252 }
252253
254+ @CacheEvict(" RoleService.isSupervisor" , allEntries = true )
253255 fun updateRoleUsers (course : Course , toRemove : List <String >, toAdd : List <String >, role : Role ) {
254256 val roleName = role.withCourse(course.slug)
255257 val realmRoleRepresentation = getRoleByName(roleName).toRepresentation()
@@ -326,7 +328,12 @@ class RoleService(
326328 val registrationID = getCurrentUsername()
327329 val user = proxy.findUserByAllCriteria(registrationID)
328330 ? : throw Exception (" User with registrationID $registrationID not found" )
331+ return proxy.isSupervisor(courseSlug, user)
329332
333+ }
334+
335+ @Cacheable(" RoleService.isSupervisor" , key = " #courseSlug + '-' + #user.id" )
336+ fun isSupervisor (courseSlug : String , user : UserRepresentation ): Boolean {
330337 val roles = user.toResource().roles().realmLevel().listEffective()
331338 return roles.any { listOf (" ${courseSlug} -supervisor" , " supervisor" ).contains(it.name) }
332339 }
0 commit comments