diff --git a/forms/src/main/resources/META-INF/resources/forms/theme/default/css/login-register.css b/forms/src/main/resources/META-INF/resources/forms/theme/default/css/login-register.css
index 8908e5277b..0fa24e8a28 100644
--- a/forms/src/main/resources/META-INF/resources/forms/theme/default/css/login-register.css
+++ b/forms/src/main/resources/META-INF/resources/forms/theme/default/css/login-register.css
@@ -330,6 +330,12 @@ a.zocial:before {
text-align: right;
}
+.rcue-login-register .background-area p.instruction {
+ font-size: 1.3em;
+ line-height: 1.3em;
+ margin-bottom: 1.53846em;
+}
+
.rcue-login-register .background-area p.instruction.instruction.second {
color: #999999;
}
diff --git a/forms/src/main/resources/META-INF/resources/forms/theme/default/login-verify-email.ftl b/forms/src/main/resources/META-INF/resources/forms/theme/default/login-verify-email.ftl
index d6c62b00af..12fb90b38b 100755
--- a/forms/src/main/resources/META-INF/resources/forms/theme/default/login-verify-email.ftl
+++ b/forms/src/main/resources/META-INF/resources/forms/theme/default/login-verify-email.ftl
@@ -1,24 +1,25 @@
<#import "template-login-action.ftl" as layout>
-<@layout.registrationLayout bodyClass=""; section>
+<@layout.registrationLayout bodyClass="reset"; section>
<#if section = "title">
- Verify email
+ Email verification
<#elseif section = "header">
- Verify email
+ Email verification
<#elseif section = "form">
-
- An email with instructions to verify your email address has been sent to you. If you don't receive this email,
-
click here to re-send the email.
+
<#elseif section = "info" >
-
-
-
#if>
@layout.registrationLayout>
\ No newline at end of file
diff --git a/services/src/main/java/org/keycloak/services/email/EmailSender.java b/services/src/main/java/org/keycloak/services/email/EmailSender.java
index 8bd181cdd6..7fb20ebf93 100644
--- a/services/src/main/java/org/keycloak/services/email/EmailSender.java
+++ b/services/src/main/java/org/keycloak/services/email/EmailSender.java
@@ -85,9 +85,15 @@ public class EmailSender {
URI uri = builder.build(realm.getId());
StringBuilder sb = new StringBuilder();
+ sb.append("Hi ").append(user.getFirstName()).append(",\n\n");
+ sb.append("Someone has created a Keycloak account with this email address. ");
+ sb.append("If this was you, click the link below to verify your email address:\n");
sb.append(uri.toString());
- sb.append("\n");
- sb.append("Expires in " + TimeUnit.SECONDS.toMinutes(realm.getAccessCodeLifespanUserAction()));
+ sb.append("\n\nThis link will expire within ").append(TimeUnit.SECONDS.toMinutes(realm.getAccessCodeLifespanUserAction()));
+ sb.append(" minutes.\n\n");
+ sb.append("If you didn't create this account, just ignore this message.\n\n");
+ sb.append("Thanks,\n");
+ sb.append("The Keycloak Team");
try {
send(user.getEmail(), "Verify email", sb.toString());
diff --git a/services/src/main/java/org/keycloak/services/resources/AccountService.java b/services/src/main/java/org/keycloak/services/resources/AccountService.java
index 94e46820c1..cfbdefa43c 100755
--- a/services/src/main/java/org/keycloak/services/resources/AccountService.java
+++ b/services/src/main/java/org/keycloak/services/resources/AccountService.java
@@ -281,8 +281,6 @@ public class AccountService {
return Response.status(Status.FORBIDDEN).build();
}
- new EmailSender().sendEmailVerification(user, realm, accessCode, uriInfo);
-
return Flows.forms(realm, request, uriInfo).setAccessCode(accessCode).setUser(user)
.forwardToAction(RequiredAction.VERIFY_EMAIL);
}
diff --git a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java
index 26b9e552e8..7d38da7a95 100644
--- a/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java
+++ b/testsuite/src/test/java/org/keycloak/testsuite/actions/RequiredActionEmailVerificationTest.java
@@ -40,6 +40,7 @@ import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.AppPage.RequestType;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.RegisterPage;
+import org.keycloak.testsuite.pages.VerifyEmailPage;
import org.keycloak.testsuite.rule.GreenMailRule;
import org.keycloak.testsuite.rule.KeycloakRule;
import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup;
@@ -80,6 +81,9 @@ public class RequiredActionEmailVerificationTest {
@WebResource
protected LoginPage loginPage;
+ @WebResource
+ protected VerifyEmailPage verifyEmailPage;
+
@WebResource
protected RegisterPage registerPage;
@@ -88,7 +92,9 @@ public class RequiredActionEmailVerificationTest {
loginPage.open();
loginPage.login("test-user@localhost", "password");
- Assert.assertTrue(driver.getPageSource().contains("Verify email"));
+ Assert.assertTrue(verifyEmailPage.isCurrent());
+
+ Assert.assertEquals(1, greenMail.getReceivedMessages().length);
MimeMessage message = greenMail.getReceivedMessages()[0];
@@ -111,7 +117,9 @@ public class RequiredActionEmailVerificationTest {
loginPage.clickRegister();
registerPage.register("firstName", "lastName", "email", "verifyEmail", "password", "password");
- Assert.assertTrue(driver.getPageSource().contains("Verify email"));
+ Assert.assertTrue(verifyEmailPage.isCurrent());
+
+ Assert.assertEquals(1, greenMail.getReceivedMessages().length);
MimeMessage message = greenMail.getReceivedMessages()[0];
@@ -128,4 +136,33 @@ public class RequiredActionEmailVerificationTest {
Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
}
+ @Test
+ public void verifyEmailResend() throws IOException, MessagingException {
+ loginPage.open();
+ loginPage.clickRegister();
+ registerPage.register("firstName2", "lastName2", "email2", "verifyEmail2", "password2", "password2");
+
+ Assert.assertTrue(verifyEmailPage.isCurrent());
+
+ Assert.assertEquals(1, greenMail.getReceivedMessages().length);
+
+ verifyEmailPage.clickResendEmail();
+
+ Assert.assertEquals(2, greenMail.getReceivedMessages().length);
+
+ MimeMessage message = greenMail.getReceivedMessages()[1];
+
+ String body = (String) message.getContent();
+
+ Pattern p = Pattern.compile("(?s).*(http://[^\\s]*).*");
+ Matcher m = p.matcher(body);
+ m.matches();
+
+ String verificationUrl = m.group(1);
+
+ driver.navigate().to(verificationUrl.trim());
+
+ Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
+ }
+
}
diff --git a/testsuite/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java b/testsuite/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java
new file mode 100644
index 0000000000..5e8c24c65b
--- /dev/null
+++ b/testsuite/src/test/java/org/keycloak/testsuite/pages/VerifyEmailPage.java
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.keycloak.testsuite.pages;
+
+import org.keycloak.testsuite.OAuthClient;
+import org.keycloak.testsuite.rule.WebResource;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+
+/**
+ * @author
Viliam Rockai
+ */
+public class VerifyEmailPage extends Page {
+
+ @WebResource
+ protected OAuthClient oauth;
+
+ @FindBy(linkText = "Click here")
+ private WebElement resendEmailLink;
+
+ @Override
+ public void open() {
+
+ }
+
+ public boolean isCurrent() {
+ return driver.getTitle().equals("Email verification");
+ }
+
+ public void clickResendEmail() {
+ resendEmailLink.click();
+ }
+
+}