Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #100 from hkeeler/master
Browse files Browse the repository at this point in the history
Refactor to new externalId format in inst search
  • Loading branch information
wpears authored Apr 3, 2017
2 parents e8502e5 + 3ac75b6 commit efe7253
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@
*/
public class ExternalId {

private String name;
private ExternalIdType externalIdType;
private String value;

public String getName() {
return name;
public ExternalId() {
}

public void setName(String name) {
this.name = name;
public ExternalIdType getExternalIdType() {
return externalIdType;
}

public void setExternalIdType(ExternalIdType externalIdType) {
this.externalIdType = externalIdType;
}

public String getValue() {
Expand All @@ -29,7 +32,7 @@ public void setValue(String value) {
@Override
public String toString() {
return "ExternalId{" +
"name='" + name + '\'' +
"externalIdType=" + externalIdType +
", value='" + value + '\'' +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package gov.cfpb.keycloak.authenticator.hmda;

/**
* Created by keelerh on 3/29/17.
*/
public class ExternalIdType {

private String code;
private String name;

public ExternalIdType() {
}

public String getCode() {
return code;
}

public void setCode(String code) {
this.code = code;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return "ExternalIdType{" +
"code='" + code + '\'' +
", name='" + name + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public void validate(ValidationContext context) {
MultivaluedMap<String, String> formData = context.getHttpRequest().getDecodedFormParameters();
List<FormMessage> errors = new ArrayList<>();

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);
Expand Down
17 changes: 5 additions & 12 deletions keycloak/themes/hmda/login/register.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,20 @@
<script>
var institutionSearchUri = "${properties.institutionSearchUri!}/institutions";
var emailExp = new RegExp("[a-zA-Z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*");
var externalIdTypeNames = {
"fdic-certificate-number": "FDIC Certificate Number",
"federal-tax-id": "Federal Tax ID",
"ncua-charter-id": "NCUA Charter Number",
"occ-charter-id": "OCC Charter Number",
"rssd-id": "RSSD ID",
"undetermined-external-id": "Unknown ID",
}
function emailToDomain(email) {
return email.split("@", 2)[1];
}
function getExternalIds(externalIds) {
var html = ''
function createExternalIdHTML(externalIds) {
var html = '';
if(externalIds.length > 0) {
html = '<dl class="usa-text-small">';
for (var i = 0; i < externalIds.length; i++) {
html += '<dt>' + externalIdTypeNames[externalIds[i].name] + ': </dt>';
html += '<dt>' + externalIds[i].externalIdType.name + ': </dt>';
html += '<dd>' + externalIds[i].value + '</dd>';
}
html += '</dl>';
}
return html;
Expand All @@ -110,7 +103,7 @@ function createHTML(institutions) {
+ institutions[i].id + '"' + checked + '>'
+ '<label for="' + institutions[i].id + '">'
+ '<strong>' + institutions[i].name + '</strong>'
+ getExternalIds(institutions[i].externalIds)
+ createExternalIdHTML(institutions[i].externalIds)
+ '</label></li>'
}
html = html + '</ul></fieldset>';
Expand Down

0 comments on commit efe7253

Please sign in to comment.