Skip to content

Commit

Permalink
fix minor bug where task points where shown as 0 for some users
Browse files Browse the repository at this point in the history
  • Loading branch information
sealexan committed Feb 26, 2024
1 parent 56c3e44 commit 003442c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/kotlin/ch/uzh/ifi/access/service/RoleService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class RoleService(
if (resByUsername == null && resByEmail == null) {
logger.debug { "RoleService: Could not find user $username" }
}
if (resByUsername == null && resByEmail != null) {
logger.debug { "RoleService: Found $username by email only" }
}
if (resByUsername != null)
return resByUsername
return resByEmail
Expand Down Expand Up @@ -150,7 +153,6 @@ class RoleService(
val role = accessRealm.roles()[Role.STUDENT.withCourse(course.slug)]
val rolesToAdd = listOf(role.toRepresentation())
logger.debug { "B: updating roles for ${username} (roles to add: ${rolesToAdd})"}
logger.debug { "Searching if ${username} is in ${role.getUserMembers(0, -1).size} members of ${role} in keycloak" }
role.getUserMembers(0, -1)
.filter {
studentMatchesUser(username, it)
Expand All @@ -159,7 +161,6 @@ class RoleService(
logger.debug { "B: removing ${rolesToAdd} from ${username}"}
accessRealm.users()[it.id].roles().realmLevel().remove(rolesToAdd)
}
logger.debug { "Comparing $username to ${accessRealm.users().list(0, -1).size} users in keycloak" }
accessRealm.users().list(0, -1).forEach {
if (studentMatchesUser(username, it) && userRegisteredForCourse(it, registrationIDs)) {
logger.debug { "B: adding roles ${rolesToAdd} to ${it.username}" }
Expand Down Expand Up @@ -187,9 +188,7 @@ class RoleService(
}

fun getAllUserIdsFor(userId: String): List<String> {
val userOptional = accessRealm.users().search(userId).stream().findFirst()
if (!userOptional.isPresent) { return emptyList() }
val user = userOptional.get()
val user = getUserRepresentationForUsername(userId) ?: return emptyList()
val results = mutableListOf<String>()
user.username?.let { results.add(it) }
user.email?.let { results.add(it) }
Expand Down

0 comments on commit 003442c

Please sign in to comment.