diff --git a/server-spi-private/src/main/java/org/keycloak/email/EmailTemplateProvider.java b/server-spi-private/src/main/java/org/keycloak/email/EmailTemplateProvider.java
index fc53d4f408..91160d15dc 100755
--- a/server-spi-private/src/main/java/org/keycloak/email/EmailTemplateProvider.java
+++ b/server-spi-private/src/main/java/org/keycloak/email/EmailTemplateProvider.java
@@ -18,6 +18,7 @@
package org.keycloak.email;
import org.keycloak.events.Event;
+import org.keycloak.models.OrganizationModel;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.provider.Provider;
@@ -77,7 +78,7 @@ public interface EmailTemplateProvider extends Provider {
void sendVerifyEmail(String link, long expirationInMinutes) throws EmailException;
- void sendOrgInviteEmail(String link, long expirationInMinutes) throws EmailException;
+ void sendOrgInviteEmail(OrganizationModel organization, String link, long expirationInMinutes) throws EmailException;
void sendEmailUpdateConfirmation(String link, long expirationInMinutes, String address) throws EmailException;
diff --git a/services/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java b/services/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java
index 57ed7a9e22..a5a93fb55c 100755
--- a/services/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java
+++ b/services/src/main/java/org/keycloak/email/freemarker/FreeMarkerEmailTemplateProvider.java
@@ -37,6 +37,7 @@ import org.keycloak.events.EventType;
import org.keycloak.forms.login.freemarker.model.UrlBean;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakUriInfo;
+import org.keycloak.models.OrganizationModel;
import org.keycloak.models.RealmModel;
import org.keycloak.models.UserModel;
import org.keycloak.sessions.AuthenticationSessionModel;
@@ -163,10 +164,11 @@ public class FreeMarkerEmailTemplateProvider implements EmailTemplateProvider {
}
@Override
- public void sendOrgInviteEmail(String link, long expirationInMinutes) throws EmailException {
+ public void sendOrgInviteEmail(OrganizationModel organization, String link, long expirationInMinutes) throws EmailException {
Map You were invited to join the " + organizationName + " organization. Click the link below to join.
If you dont want to join the organization, just ignore this message.
")); String orgToken = UriUtils.parseQueryParameters(link, false).values().stream().map(strings -> strings.get(0)).findFirst().orElse(null); Assert.assertNotNull(orgToken); driver.navigate().to(link.trim()); @@ -144,7 +154,8 @@ public class OrganizationInvitationLinkTest extends AbstractOrganizationTest { MimeMessage message = greenMail.getLastReceivedMessage(); Assert.assertNotNull(message); - String link = MailUtils.getPasswordResetEmailLink(message); + EmailBody body = MailUtils.getBody(message); + String link = MailUtils.getLink(body.getHtml()); String orgToken = UriUtils.parseQueryParameters(link, false).values().stream().map(strings -> strings.get(0)).findFirst().orElse(null); Assert.assertNotNull(orgToken); driver.navigate().to(link.trim()); @@ -173,7 +184,8 @@ public class OrganizationInvitationLinkTest extends AbstractOrganizationTest { setTimeOffset((int) TimeUnit.DAYS.toSeconds(1)); MimeMessage message = greenMail.getLastReceivedMessage(); Assert.assertNotNull(message); - String link = MailUtils.getPasswordResetEmailLink(message); + EmailBody body = MailUtils.getBody(message); + String link = MailUtils.getLink(body.getHtml()); String orgToken = UriUtils.parseQueryParameters(link, false).values().stream().map(strings -> strings.get(0)).findFirst().orElse(null); Assert.assertNotNull(orgToken); driver.navigate().to(link.trim()); diff --git a/themes/src/main/resources/theme/base/email/html/org-invite.ftl b/themes/src/main/resources/theme/base/email/html/org-invite.ftl index d7f72e3e20..78811f0eda 100644 --- a/themes/src/main/resources/theme/base/email/html/org-invite.ftl +++ b/themes/src/main/resources/theme/base/email/html/org-invite.ftl @@ -1,4 +1,4 @@ <#import "template.ftl" as layout> <@layout.emailLayout> -${kcSanitize(msg("orgInviteBodyHtml", link, linkExpiration, realmName, linkExpirationFormatter(linkExpiration)))?no_esc} +${kcSanitize(msg("orgInviteBodyHtml", link, linkExpiration, realmName, organization.name, linkExpirationFormatter(linkExpiration)))?no_esc} @layout.emailLayout> diff --git a/themes/src/main/resources/theme/base/email/messages/messages_en.properties b/themes/src/main/resources/theme/base/email/messages/messages_en.properties index dc593deada..b40fe28de4 100755 --- a/themes/src/main/resources/theme/base/email/messages/messages_en.properties +++ b/themes/src/main/resources/theme/base/email/messages/messages_en.properties @@ -1,7 +1,9 @@ emailVerificationSubject=Verify email emailVerificationBody=Someone has created a {2} account with this email address. If this was you, click the link below to verify your email address\n\n{0}\n\nThis link will expire within {3}.\n\nIf you didn''t create this account, just ignore this message. emailVerificationBodyHtml=Someone has created a {2} account with this email address. If this was you, click the link below to verify your email address
Link to e-mail address verification
This link will expire within {3}.
If you didn''t create this account, just ignore this message.
-orgInviteBodyHtml=Someone has invited your account {2} account to join their keycloak organization! Click the link below to join.
This link will expire within {3}.
If you don't want to join the organization, just ignore this message.
+orgInviteSubject=Invitation to join the {0} organization +orgInviteBody=You were invited to join the "{3}" organization. Click the link below to join.\n\n{0}\n\nThis link will expire within {4}.\n\nIf you don't want to join the organization, just ignore this message. +orgInviteBodyHtml=You were invited to join the {3} organization. Click the link below to join.
This link will expire within {4}.
If you don't want to join the organization, just ignore this message.
emailUpdateConfirmationSubject=Verify new email emailUpdateConfirmationBody=To update your {2} account with email address {1}, click the link below\n\n{0}\n\nThis link will expire within {3}.\n\nIf you don''t want to proceed with this modification, just ignore this message. emailUpdateConfirmationBodyHtml=To update your {2} account with email address {1}, click the link below
This link will expire within {3}.
If you don''t want to proceed with this modification, just ignore this message.
diff --git a/themes/src/main/resources/theme/base/email/text/org-invite.ftl b/themes/src/main/resources/theme/base/email/text/org-invite.ftl index afc32a7230..b74abe0d0a 100644 --- a/themes/src/main/resources/theme/base/email/text/org-invite.ftl +++ b/themes/src/main/resources/theme/base/email/text/org-invite.ftl @@ -1,2 +1,2 @@ <#ftl output_format="plainText"> -${kcSanitize(msg("orgInviteBodyHtml", link, linkExpiration, realmName, linkExpirationFormatter(linkExpiration)))} +${kcSanitize(msg("orgInviteBody", link, linkExpiration, realmName, organization.name, linkExpirationFormatter(linkExpiration)))}