Merge pull request #1273 from girirajsharma/master

[KEYCLOAK-1334] Forgot password page does not return validation error
This commit is contained in:
Stian Thorgersen 2015-05-26 08:56:04 +02:00
commit ab934f3d35
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 {