Skip to content

Commit 1892736

Browse files
committed
Fix (?) registration bug and re-enable renameIDs
1 parent bc0983a commit 1892736

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

src/main/kotlin/ch/uzh/ifi/access/config/CacheConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ class CacheConfig {
3838
class CacheInitListener(val cacheInitService: CacheInitService) : ApplicationListener<ApplicationReadyEvent> {
3939
override fun onApplicationEvent(event: ApplicationReadyEvent) {
4040
cacheInitService.initCache()
41-
//courseService.renameIDs()
41+
cacheInitService.renameIDs()
4242
}
4343
}

src/main/kotlin/ch/uzh/ifi/access/service/CourseService.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,12 @@ class CourseService(
329329
val newUsersSet = registrationIDs.toSet()
330330
val existingUsersSet = existingUsers.toSet()
331331

332+
logger.debug { "existingUsersSet: $existingUsers" }
333+
logger.debug { "newUsersSet: $newUsersSet" }
332334
val removedUsers = existingUsersSet.minus(newUsersSet).toList()
333335
val addedUsers = newUsersSet.minus(existingUsersSet).toList()
336+
logger.debug { "removedUsers: $removedUsers" }
337+
logger.debug { "addedUsers: $addedUsers" }
334338

335339
when (role) {
336340
Role.SUPERVISOR -> course.supervisors = newUsersSet.toMutableSet()

src/main/kotlin/ch/uzh/ifi/access/service/RoleService.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ class RoleService(
213213
fun initializeUserRoles(username: String) {
214214
try {
215215
semaphore.acquire()
216+
// evict the username to ensure we get a UserRepresentation and not null
217+
// this only happens on first login anyway, and should not be necessary,
218+
// but if someone deletes a user from Keycloak manually, then the caching is broken even after a reboot
219+
cacheManager.getCache("RoleService.findUserByAllCriteria")?.evict(username);
216220
val user = proxy.findUserByAllCriteria(username)
217221
if (user == null) {
218222
logger.error { "Trying to initialize roles for $username: no matching username in Keycloak" }

0 commit comments

Comments
 (0)