From 8b5f3fe967ccd0bec68a50ab9134d945011d30fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Str=C3=B6der?= Date: Tue, 23 Feb 2021 01:26:15 +0100 Subject: [PATCH] properly extract List instance --- .../events/logging/LastLoginEventListenerProvider.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java b/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java index 2854230..81a23a6 100644 --- a/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java +++ b/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java @@ -10,6 +10,7 @@ import org.keycloak.models.RealmModel; import org.keycloak.models.RealmProvider; import org.keycloak.models.UserModel; +import java.util.List; import java.util.Map; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -36,10 +37,10 @@ public class LastLoginEventListenerProvider implements EventListenerProvider { if (user != null) { log.info("Updating last login status for user: " + event.getUserId()); - Map userAttrs = user.getAttributes(); + Map> userAttrs = user.getAttributes(); if (userAttrs.containsKey("last-login")) { - String userLastLogin = userAttrs.get("last-login").toString(); - user.setSingleAttribute("prior-login", userLastLogin.substring(1, userLastLogin.length()-1)); + String userLastLogin = userAttrs.get("last-login").get(0); + user.setSingleAttribute("prior-login", userLastLogin); } // Use current server time for login event