[KEYCLOAK-1334] Forgot password page does not return validation error

message when input field is empty
This commit is contained in:
girirajsharma 2015-05-23 01:18:23 +05:30
parent 0951c11aa6
commit 8e7e208265
2 changed files with 26 additions and 0 deletions

View file

@ -892,6 +892,13 @@ public class LoginActionsService {
ClientSessionModel clientSession = accessCode.getClientSession();
String username = formData.getFirst("username");
if(username == null || username.isEmpty()) {
event.error(Errors.USERNAME_MISSING);
return session.getProvider(LoginFormsProvider.class)
.setError(Messages.MISSING_USERNAME)
.setClientSessionCode(accessCode.getCode())
.createPasswordReset();
}
ClientModel client = clientSession.getClient();
if (client == null) {

View file

@ -324,6 +324,25 @@ public class ResetPasswordTest {
events.expectRequiredAction(EventType.SEND_RESET_PASSWORD).user((String) null).session((String) null).detail(Details.USERNAME, "invalid").removeDetail(Details.EMAIL).removeDetail(Details.CODE_ID).error("user_not_found").assertEvent();
}
@Test
public void resetPasswordMissingUsername() throws IOException, MessagingException, InterruptedException {
loginPage.open();
loginPage.resetPassword();
resetPasswordPage.assertCurrent();
resetPasswordPage.changePassword("");
resetPasswordPage.assertCurrent();
assertEquals("Please specify username.", resetPasswordPage.getErrorMessage());
assertEquals(0, greenMail.getReceivedMessages().length);
events.expectRequiredAction(EventType.SEND_RESET_PASSWORD).client((String) null).user((String) null).session((String) null).clearDetails().error("username_missing").assertEvent();
}
@Test
public void resetPasswordExpiredCode() throws IOException, MessagingException, InterruptedException {