Respect the locale set to a user when redering verify email pages
Closes #34063 Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
This commit is contained in:
parent
6efeb0ad37
commit
ee38d551ce
2 changed files with 28 additions and 3 deletions
|
@ -1,13 +1,13 @@
|
|||
/*
|
||||
* Copyright 2017 Red Hat, Inc. and/or its affiliates
|
||||
* and other contributors as indicated by the @author tags.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -82,6 +82,7 @@ public class VerifyEmailActionTokenHandler extends AbstractActionTokenHandler<Ve
|
|||
return session.getProvider(LoginFormsProvider.class)
|
||||
.setAuthenticationSession(authSession)
|
||||
.setInfo(Messages.EMAIL_VERIFIED_ALREADY, user.getEmail())
|
||||
.setUser(user)
|
||||
.createInfoPage();
|
||||
}
|
||||
|
||||
|
@ -102,6 +103,7 @@ public class VerifyEmailActionTokenHandler extends AbstractActionTokenHandler<Ve
|
|||
.setAuthenticationSession(authSession)
|
||||
.setSuccess(Messages.CONFIRM_EMAIL_ADDRESS_VERIFICATION, user.getEmail())
|
||||
.setAttribute(Constants.TEMPLATE_ATTR_ACTION_URI, confirmUri)
|
||||
.setUser(user)
|
||||
.createInfoPage();
|
||||
}
|
||||
|
||||
|
@ -126,6 +128,7 @@ public class VerifyEmailActionTokenHandler extends AbstractActionTokenHandler<Ve
|
|||
return session.getProvider(LoginFormsProvider.class)
|
||||
.setAuthenticationSession(authSession)
|
||||
.setSuccess(Messages.EMAIL_VERIFIED)
|
||||
.setUser(user)
|
||||
.createInfoPage();
|
||||
}
|
||||
|
||||
|
|
|
@ -73,9 +73,11 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assume;
|
||||
import org.keycloak.testsuite.util.WaitUtils;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
@ -241,6 +243,26 @@ public class RequiredActionEmailVerificationTest extends AbstractTestRealmKeyclo
|
|||
events.expectLogin().user(userId).session(mailCodeId).detail(Details.USERNAME, "verifyemail").assertEvent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyEmailRegisterSetLocale() throws IOException, MessagingException {
|
||||
RealmRepresentation realm = testRealm().toRepresentation();
|
||||
realm.setInternationalizationEnabled(true);
|
||||
realm.setSupportedLocales(Set.of("en", "pt"));
|
||||
testRealm().update(realm);
|
||||
loginPage.open();
|
||||
loginPage.clickRegister();
|
||||
loginPage.openLanguage("Português");
|
||||
registerPage.register("firstName", "lastName", "locale@mail.com", "locale", "password", "password");
|
||||
|
||||
Assert.assertEquals(1, greenMail.getReceivedMessages().length);
|
||||
MimeMessage message = greenMail.getReceivedMessages()[0];
|
||||
String verificationUrl = getEmailLink(message);
|
||||
|
||||
driver.manage().deleteAllCookies();
|
||||
driver.navigate().to(verificationUrl.trim());
|
||||
assertTrue(driver.getPageSource().contains("Confirme a validade do endereço"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyEmailFromAnotherAccountWhenUserIsAuthenticated() throws Exception {
|
||||
loginPage.open();
|
||||
|
|
Loading…
Reference in a new issue