diff --git a/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java b/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java index 79d20d5011..55ddb9b50b 100755 --- a/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java +++ b/services/src/main/java/org/keycloak/services/resources/LoginActionsService.java @@ -623,6 +623,7 @@ public class LoginActionsService { if (clientSession.getAction().equals(ClientSessionModel.Action.RECOVER_PASSWORD.name())) { String actionCookieValue = getActionCookie(); if (actionCookieValue == null || !actionCookieValue.equals(userSession.getId())) { + session.sessions().removeClientSession(realm, clientSession); return session.getProvider(LoginFormsProvider.class) .setSuccess(Messages.ACCOUNT_PASSWORD_UPDATED) .createInfoPage(); @@ -657,6 +658,7 @@ public class LoginActionsService { String actionCookieValue = getActionCookie(); if (actionCookieValue == null || !actionCookieValue.equals(userSession.getId())) { + session.sessions().removeClientSession(realm, clientSession); return session.getProvider(LoginFormsProvider.class) .setSuccess(Messages.EMAIL_VERIFIED) .createInfoPage(); diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/MailServer.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/MailServer.java index 1acaafb2a9..f56f0aaaa3 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/MailServer.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/MailServer.java @@ -5,6 +5,7 @@ import com.icegreen.greenmail.util.ServerSetup; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage.RecipientType; +import javax.mail.internet.MimeMultipart; public class MailServer { @@ -22,9 +23,20 @@ public class MailServer { if (greenMail.waitForIncomingEmail(Long.MAX_VALUE, c + 1)) { MimeMessage message = greenMail.getReceivedMessages()[c++]; + System.out.println("-------------------------------------------------------"); System.out.println("Received mail to " + message.getRecipients(RecipientType.TO)[0]); - System.out.println(); - System.out.println(message.getContent()); + if (message.getContent() instanceof MimeMultipart) { + MimeMultipart mimeMultipart = (MimeMultipart) message.getContent(); + for (int i = 0; i < mimeMultipart.getCount(); i++) { + System.out.println("----"); + System.out.println(mimeMultipart.getBodyPart(i).getContentType() + ":"); + System.out.println(); + System.out.println(mimeMultipart.getBodyPart(i).getContent()); + } + } else { + System.out.println(); + System.out.println(message.getContent()); + } System.out.println("-------------------------------------------------------"); } }