[KEYCLOAK-2645] Reset password page says 'You need to change your password to activate your account.'
This commit is contained in:
parent
2be78a0239
commit
6a528a3ee6
5 changed files with 16 additions and 1 deletions
|
@ -62,6 +62,8 @@ import java.net.URI;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static org.keycloak.models.UserModel.RequiredAction.UPDATE_PASSWORD;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
|
||||||
*/
|
*/
|
||||||
|
@ -132,7 +134,8 @@ public class FreeMarkerLoginFormsProvider implements LoginFormsProvider {
|
||||||
page = LoginFormsPages.LOGIN_UPDATE_PROFILE;
|
page = LoginFormsPages.LOGIN_UPDATE_PROFILE;
|
||||||
break;
|
break;
|
||||||
case UPDATE_PASSWORD:
|
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;
|
page = LoginFormsPages.LOGIN_UPDATE_PASSWORD;
|
||||||
break;
|
break;
|
||||||
case VERIFY_EMAIL:
|
case VERIFY_EMAIL:
|
||||||
|
|
|
@ -77,6 +77,8 @@ public class Messages {
|
||||||
|
|
||||||
public static final String UPDATE_PROFILE = "updateProfileMessage";
|
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 UPDATE_PASSWORD = "updatePasswordMessage";
|
||||||
|
|
||||||
public static final String VERIFY_EMAIL = "verifyEmailMessage";
|
public static final String VERIFY_EMAIL = "verifyEmailMessage";
|
||||||
|
|
|
@ -36,6 +36,9 @@ public class LoginPasswordUpdatePage extends LanguageComboboxAwarePage {
|
||||||
@FindBy(className = "alert-error")
|
@FindBy(className = "alert-error")
|
||||||
private WebElement loginErrorMessage;
|
private WebElement loginErrorMessage;
|
||||||
|
|
||||||
|
@FindBy(xpath = "//span[@class='kc-feedback-text']")
|
||||||
|
private WebElement feedbackMessage;
|
||||||
|
|
||||||
public void changePassword(String newPassword, String passwordConfirm) {
|
public void changePassword(String newPassword, String passwordConfirm) {
|
||||||
newPasswordInput.sendKeys(newPassword);
|
newPasswordInput.sendKeys(newPassword);
|
||||||
passwordConfirmInput.sendKeys(passwordConfirm);
|
passwordConfirmInput.sendKeys(passwordConfirm);
|
||||||
|
@ -55,4 +58,7 @@ public class LoginPasswordUpdatePage extends LanguageComboboxAwarePage {
|
||||||
return loginErrorMessage != null ? loginErrorMessage.getText() : null;
|
return loginErrorMessage != null ? loginErrorMessage.getText() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFeedbackMessage() {
|
||||||
|
return feedbackMessage.getText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -258,6 +259,8 @@ public class ResetPasswordTest extends AbstractTestRealmKeycloakTest {
|
||||||
|
|
||||||
updatePasswordPage.assertCurrent();
|
updatePasswordPage.assertCurrent();
|
||||||
|
|
||||||
|
assertEquals("You need to change your password.", updatePasswordPage.getFeedbackMessage());
|
||||||
|
|
||||||
updatePasswordPage.changePassword(password, password);
|
updatePasswordPage.changePassword(password, password);
|
||||||
|
|
||||||
events.expectRequiredAction(EventType.UPDATE_PASSWORD).user(userId).detail(Details.USERNAME, username.trim()).assertEvent();
|
events.expectRequiredAction(EventType.UPDATE_PASSWORD).user(userId).detail(Details.USERNAME, username.trim()).assertEvent();
|
||||||
|
|
|
@ -160,6 +160,7 @@ confirmLinkIdpContinue=Add to existing account
|
||||||
configureTotpMessage=You need to set up Mobile Authenticator to activate your 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.
|
updateProfileMessage=You need to update your user profile to activate your account.
|
||||||
updatePasswordMessage=You need to change your password 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.
|
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}.
|
linkIdpMessage=You need to verify your email address to link your account with {0}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue