Skip to content

Commit 40cf520

Browse files
committed
debugging participation issue
1 parent e96870c commit 40cf520

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import org.springframework.web.filter.CommonsRequestLoggingFilter
2828
import java.nio.file.Path
2929
import java.time.Duration
3030
import java.time.Instant
31+
import java.time.LocalDate
3132
import java.time.LocalDateTime
33+
import java.time.ZoneId
3234

3335

3436
@AllArgsConstructor
@@ -159,13 +161,16 @@ class AuthenticationSuccessListener(
159161
else {
160162
try {
161163
val lastSync = currentAttributes["roles_synced_at"]!!.first()
162-
val timeStamp = lastSync.substring(0, Math.min(lastSync.length, lastSync.indexOf('.') + 4)) + "Z"
163-
val dateTime = Instant.parse(timeStamp)
164-
val now = Instant.now()
165-
if (Duration.between(dateTime, now).toMinutes() > 10) {
164+
val lastSyncInstant = LocalDateTime.parse(lastSync)
165+
val now = LocalDateTime.now()
166+
val diff = Duration.between(lastSyncInstant, now).toMinutes()
167+
if (diff > 10) {
166168
logger.debug { "syncing $username to courses after more than 10min" }
167169
courseService.updateStudentRoles(username)
168170
}
171+
else {
172+
logger.debug { "only $diff minutes elapsed since last sync of $username at ${lastSync} (now: $now)" }
173+
}
169174
} catch (e: Exception) {
170175
logger.debug { "problem ($e, ${e.stackTrace}) with sync calculation; syncing $username to courses anyway" }
171176
courseService.updateStudentRoles(username)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class RoleService(
144144
fun updateStudentRoles(course: Course, registrationIDs: Set<String>, username: String) {
145145
val role = accessRealm.roles()[Role.STUDENT.withCourse(course.slug)]
146146
val rolesToAdd = listOf(role.toRepresentation())
147+
logger.debug { "registered students for ${course.slug}: $registrationIDs"}
147148
logger.debug { "B: updating roles for ${username} (roles to add: ${rolesToAdd})"}
148149
logger.debug { "Searching if ${username} is in ${role.getUserMembers(0, -1).size} members of ${role} in keycloak" }
149150
role.getUserMembers(0, -1)

0 commit comments

Comments
 (0)