KEYCLOAK-18273 Display Idp displayName if available (#8087)

Co-authored-by: moritz.hilberg <moritz.hilberg@pwc.com>
This commit is contained in:
Moritz H 2022-08-30 20:32:27 +02:00 committed by GitHub
parent 94de015440
commit c4971d179c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View file

@ -138,6 +138,10 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
String idpAlias = brokerContext.getIdpConfig().getAlias();
String idpDisplayName = brokerContext.getIdpConfig().getDisplayName();
idpAlias = ObjectUtil.capitalize(idpAlias);
String displayName = idpAlias;
if (!ObjectUtil.isBlank(brokerContext.getIdpConfig().getDisplayName())) {
displayName = brokerContext.getIdpConfig().getDisplayName();
}
if (idpDisplayName != null && idpDisplayName.length() > 0) {
idpAlias = ObjectUtil.capitalize(idpDisplayName);
@ -145,8 +149,9 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
attributes.put("identityProviderContext", brokerContext);
attributes.put("identityProviderAlias", idpAlias);
attributes.put("identityProviderDisplayName", displayName);
List<Object> subjectAttrs = Arrays.asList(idpAlias);
List<Object> subjectAttrs = Arrays.asList(displayName);
send("identityProviderLinkSubject", subjectAttrs, "identity-provider-link.ftl", attributes);
}

View file

@ -1,4 +1,4 @@
<#import "template.ftl" as layout>
<@layout.emailLayout>
${kcSanitize(msg("identityProviderLinkBodyHtml", identityProviderAlias, realmName, identityProviderContext.username, link, linkExpiration, linkExpirationFormatter(linkExpiration)))?no_esc}
${kcSanitize(msg("identityProviderLinkBodyHtml", identityProviderDisplayName, realmName, identityProviderContext.username, link, linkExpiration, linkExpirationFormatter(linkExpiration)))?no_esc}
</@layout.emailLayout>

View file

@ -1,2 +1,2 @@
<#ftl output_format="plainText">
${msg("identityProviderLinkBody", identityProviderAlias, realmName, identityProviderContext.username, link, linkExpiration, linkExpirationFormatter(linkExpiration))}
${msg("identityProviderLinkBody", identityProviderDisplayName, realmName, identityProviderContext.username, link, linkExpiration, linkExpirationFormatter(linkExpiration))}