Merge pull request #1562 from velias/KEYCLOAK-1741

KEYCLOAK-1741 - Login form keeps "Username or email" field value after reshown due validation error
This commit is contained in:
Bill Burke 2015-08-27 09:05:40 -04:00
commit 24147a3d84
3 changed files with 25 additions and 0 deletions

View file

@ -419,6 +419,7 @@ public class AuthenticationProcessor {
LoginFormsProvider provider = getSession().getProvider(LoginFormsProvider.class) LoginFormsProvider provider = getSession().getProvider(LoginFormsProvider.class)
.setUser(getUser()) .setUser(getUser())
.setActionUri(action) .setActionUri(action)
.setFormData(request.getDecodedFormParameters())
.setClientSessionCode(accessCode); .setClientSessionCode(accessCode);
if (getForwardedErrorMessage() != null) { if (getForwardedErrorMessage() != null) {
provider.addError(getForwardedErrorMessage()); provider.addError(getForwardedErrorMessage());

View file

@ -129,6 +129,10 @@ public class LoginTest {
loginPage.assertCurrent(); loginPage.assertCurrent();
// KEYCLOAK-1741 - assert form field values kept
Assert.assertEquals("login-test", loginPage.getUsername());
Assert.assertEquals("", loginPage.getPassword());
Assert.assertEquals("Invalid username or password.", loginPage.getError()); Assert.assertEquals("Invalid username or password.", loginPage.getError());
events.expectLogin().user(userId).session((String) null).error("invalid_user_credentials") events.expectLogin().user(userId).session((String) null).error("invalid_user_credentials")
@ -144,6 +148,10 @@ public class LoginTest {
loginPage.assertCurrent(); loginPage.assertCurrent();
// KEYCLOAK-1741 - assert form field values kept
Assert.assertEquals("login-test", loginPage.getUsername());
Assert.assertEquals("", loginPage.getPassword());
Assert.assertEquals("Invalid username or password.", loginPage.getError()); Assert.assertEquals("Invalid username or password.", loginPage.getError());
events.expectLogin().user(userId).session((String) null).error("invalid_user_credentials") events.expectLogin().user(userId).session((String) null).error("invalid_user_credentials")
@ -167,6 +175,10 @@ public class LoginTest {
loginPage.assertCurrent(); loginPage.assertCurrent();
// KEYCLOAK-1741 - assert form field values kept
Assert.assertEquals("login-test", loginPage.getUsername());
Assert.assertEquals("", loginPage.getPassword());
Assert.assertEquals("Account is disabled, contact admin.", loginPage.getError()); Assert.assertEquals("Account is disabled, contact admin.", loginPage.getError());
events.expectLogin().user(userId).session((String) null).error("user_disabled") events.expectLogin().user(userId).session((String) null).error("user_disabled")
@ -198,6 +210,10 @@ public class LoginTest {
loginPage.assertCurrent(); loginPage.assertCurrent();
// KEYCLOAK-1741 - assert form field values kept
Assert.assertEquals("login-test", loginPage.getUsername());
Assert.assertEquals("", loginPage.getPassword());
Assert.assertEquals("Account is disabled, contact admin.", loginPage.getError()); Assert.assertEquals("Account is disabled, contact admin.", loginPage.getError());
events.expectLogin().user(userId).session((String) null).error("user_disabled") events.expectLogin().user(userId).session((String) null).error("user_disabled")
@ -221,6 +237,10 @@ public class LoginTest {
loginPage.assertCurrent(); loginPage.assertCurrent();
// KEYCLOAK-1741 - assert form field values kept
Assert.assertEquals("invalid", loginPage.getUsername());
Assert.assertEquals("", loginPage.getPassword());
Assert.assertEquals("Invalid username or password.", loginPage.getError()); Assert.assertEquals("Invalid username or password.", loginPage.getError());
events.expectLogin().user((String) null).session((String) null).error("user_not_found") events.expectLogin().user((String) null).session((String) null).error("user_not_found")

View file

@ -112,6 +112,10 @@ public class LoginPage extends AbstractPage {
return usernameInput.getAttribute("value"); return usernameInput.getAttribute("value");
} }
public String getPassword() {
return passwordInput.getAttribute("value");
}
public void cancel() { public void cancel() {
cancelButton.click(); cancelButton.click();
} }