From 4c68b69b0bf0d6421589e03e4baf8bbbe5138caa Mon Sep 17 00:00:00 2001 From: Hiroyuki Wada Date: Sat, 2 Nov 2024 14:01:08 +0900 Subject: [PATCH] fix: ignore discriminator if the value is "0" --- .../keycloak/social/discord/DiscordIdentityProvider.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/keycloak/social/discord/DiscordIdentityProvider.java b/src/main/java/org/keycloak/social/discord/DiscordIdentityProvider.java index e18227a..4659183 100755 --- a/src/main/java/org/keycloak/social/discord/DiscordIdentityProvider.java +++ b/src/main/java/org/keycloak/social/discord/DiscordIdentityProvider.java @@ -69,7 +69,12 @@ protected String getProfileEndpointForValidation(EventBuilder event) { protected BrokeredIdentityContext extractIdentityFromProfile(EventBuilder event, JsonNode profile) { BrokeredIdentityContext user = new BrokeredIdentityContext(getJsonProperty(profile, "id"), getConfig()); - user.setUsername(getJsonProperty(profile, "username") + "#" + getJsonProperty(profile, "discriminator")); + String username = getJsonProperty(profile, "username"); + String discriminator = getJsonProperty(profile, "discriminator"); + if (!discriminator.equals("0")) { + username = username + "#" + discriminator; + } + user.setUsername(username); user.setEmail(getJsonProperty(profile, "email")); user.setIdp(this);