File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
src/main/kotlin/ch/uzh/ifi/access Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,9 @@ import org.springframework.web.filter.CommonsRequestLoggingFilter
28
28
import java.nio.file.Path
29
29
import java.time.Duration
30
30
import java.time.Instant
31
+ import java.time.LocalDate
31
32
import java.time.LocalDateTime
33
+ import java.time.ZoneId
32
34
33
35
34
36
@AllArgsConstructor
@@ -159,13 +161,16 @@ class AuthenticationSuccessListener(
159
161
else {
160
162
try {
161
163
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 ) {
166
168
logger.debug { " syncing $username to courses after more than 10min" }
167
169
courseService.updateStudentRoles(username)
168
170
}
171
+ else {
172
+ logger.debug { " only $diff minutes elapsed since last sync of $username at ${lastSync} (now: $now )" }
173
+ }
169
174
} catch (e: Exception ) {
170
175
logger.debug { " problem ($e , ${e.stackTrace} ) with sync calculation; syncing $username to courses anyway" }
171
176
courseService.updateStudentRoles(username)
Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ class RoleService(
144
144
fun updateStudentRoles (course : Course , registrationIDs : Set <String >, username : String ) {
145
145
val role = accessRealm.roles()[Role .STUDENT .withCourse(course.slug)]
146
146
val rolesToAdd = listOf (role.toRepresentation())
147
+ logger.debug { " registered students for ${course.slug} : $registrationIDs " }
147
148
logger.debug { " B: updating roles for ${username} (roles to add: ${rolesToAdd} )" }
148
149
logger.debug { " Searching if ${username} is in ${role.getUserMembers(0 , - 1 ).size} members of ${role} in keycloak" }
149
150
role.getUserMembers(0 , - 1 )
You can’t perform that action at this time.
0 commit comments