[KEYCLOAK-2645] Reset password page says 'You need to change your password to activate your account.'

This commit is contained in:
Bruno Oliveira 2017-11-29 06:43:01 -02:00 committed by Stian Thorgersen
parent 2be78a0239
commit 6a528a3ee6
5 changed files with 16 additions and 1 deletions

View file

@ -62,6 +62,8 @@ import java.net.URI;
import java.text.MessageFormat;
import java.util.*;
import static org.keycloak.models.UserModel.RequiredAction.UPDATE_PASSWORD;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/
@ -132,7 +134,8 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
page = LoginFormsPages.LOGIN_UPDATE_PROFILE;
break;
case UPDATE_PASSWORD:
actionMessage = Messages.UPDATE_PASSWORD;
boolean isRequestedByAdmin = user.getRequiredActions().stream().filter(Objects::nonNull).anyMatch(UPDATE_PASSWORD.toString()::contains);
actionMessage = isRequestedByAdmin ? Messages.UPDATE_PASSWORD : Messages.RESET_PASSWORD;
page = LoginFormsPages.LOGIN_UPDATE_PASSWORD;
break;
case VERIFY_EMAIL:

View file

@ -77,6 +77,8 @@ public class Messages {
public static final String UPDATE_PROFILE = "updateProfileMessage";
public static final String RESET_PASSWORD = "resetPasswordMessage";
public static final String UPDATE_PASSWORD = "updatePasswordMessage";
public static final String VERIFY_EMAIL = "verifyEmailMessage";

View file

@ -36,6 +36,9 @@ public class LoginPasswordUpdatePage extends LanguageComboboxAwarePage {
@FindBy(className = "alert-error")
private WebElement loginErrorMessage;
@FindBy(xpath = "//span[@class='kc-feedback-text']")
private WebElement feedbackMessage;
public void changePassword(String newPassword, String passwordConfirm) {
newPasswordInput.sendKeys(newPassword);
passwordConfirmInput.sendKeys(passwordConfirm);
@ -55,4 +58,7 @@ public class LoginPasswordUpdatePage extends LanguageComboboxAwarePage {
return loginErrorMessage != null ? loginErrorMessage.getText() : null;
}
public String getFeedbackMessage() {
return feedbackMessage.getText();
}
}

View file

@ -50,6 +50,7 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.*;
import static org.junit.Assert.*;
/**
@ -258,6 +259,8 @@ public class ResetPasswordTest extends AbstractTestRealmKeycloakTest {
updatePasswordPage.assertCurrent();
assertEquals("You need to change your password.", updatePasswordPage.getFeedbackMessage());
updatePasswordPage.changePassword(password, password);
events.expectRequiredAction(EventType.UPDATE_PASSWORD).user(userId).detail(Details.USERNAME, username.trim()).assertEvent();

View file

@ -160,6 +160,7 @@ confirmLinkIdpContinue=Add to existing account
configureTotpMessage=You need to set up Mobile Authenticator to activate your account.
updateProfileMessage=You need to update your user profile to activate your account.
updatePasswordMessage=You need to change your password to activate your account.
resetPasswordMessage=You need to change your password.
verifyEmailMessage=You need to verify your email address to activate your account.
linkIdpMessage=You need to verify your email address to link your account with {0}.