From 0cbc7e66391c9eae0b293b89c96bf9e42b66b4c1 Mon Sep 17 00:00:00 2001 From: Hans Keeler Date: Thu, 9 Mar 2017 18:02:19 -0500 Subject: [PATCH] Remove redundant blank email field error --- .../hmda/HmdaValidInstitutionsFormAction.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java index c4efb53..72ae2b0 100644 --- a/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java +++ b/keycloak/providers/authenticator/hmda/src/main/java/gov/cfpb/keycloak/authenticator/hmda/HmdaValidInstitutionsFormAction.java @@ -43,6 +43,16 @@ public void validate(ValidationContext context) { logger.info("Form data: " + formData); + // Get email field. If not populated, there is no point in proceeding. The email field check is + // already checked by core Keycloak, so there's no need for a dupe context.error() here. + String emailFieldVal = formData.getFirst(RegistrationPage.FIELD_EMAIL); + if(Validation.isBlank(emailFieldVal)) { + context.success(); + + return; + } + + // Get the institutions field, returning with error if not set. String instFieldVal = formData.getFirst(FIELD_INSTITUTIONS); if (Validation.isBlank(instFieldVal)) { errors.add(new FormMessage(FIELD_INSTITUTIONS, MISSING_INSTITUTION_MESSAGE)); @@ -55,8 +65,7 @@ public void validate(ValidationContext context) { Set userInstIds = new HashSet<>(Arrays.asList(instFieldVal.split(","))); try { - String email = formData.getFirst(RegistrationPage.FIELD_EMAIL); - domain = email.split("@")[1]; + domain = emailFieldVal.split("@")[1]; List domainInsts = institutionService.findInstitutionsByDomain(domain);