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);