From b0671c4d4cff416ef4116c7c7b7c8360b1fb031e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Str=C3=B6der?= Date: Tue, 23 Feb 2021 01:37:18 +0100 Subject: [PATCH] added sanity check for non-existent or empty last-login value --- .../events/logging/LastLoginEventListenerProvider.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 81a23a6..1c6cb38 100644 --- a/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java +++ b/src/main/java/de/scimeda/keycloak/events/logging/LastLoginEventListenerProvider.java @@ -40,7 +40,9 @@ public class LastLoginEventListenerProvider implements EventListenerProvider { Map> userAttrs = user.getAttributes(); if (userAttrs.containsKey("last-login")) { String userLastLogin = userAttrs.get("last-login").get(0); - user.setSingleAttribute("prior-login", userLastLogin); + if (userLastLogin != null && !userLastLogin.isEmpty()) { + user.setSingleAttribute("prior-login", userLastLogin); + } } // Use current server time for login event