Skip to content

Commit

Permalink
Merge pull request #16 from 2060-io/dev
Browse files Browse the repository at this point in the history
citizen-registry: fixed copy-paste error that prevented detecting an already created identity in some specific cases
  • Loading branch information
mjfelis authored Feb 20, 2024
2 parents 7f6b890 + 681130e commit b07c761
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 35 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/ci-biometric-authenticator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
paths:
- 'biometric-authenticator/**'
- '.github/workflows/ci-biometric-authenticator.yml'
pull_request_target:
branches: [ main, dev ]
paths:
- 'biometric-authenticator/**'
- '.github/workflows/ci-biometric-authenticator.yml'
workflow_dispatch:

env:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-citizen-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
paths:
- 'citizen-registry/**'
- '.github/workflows/ci-citizen-registry.yml'
pull_request_target:
branches: [ main, dev ]
paths:
- 'citizen-registry/**'
- '.github/workflows/ci-citizen-registry.yml'
workflow_dispatch:

env:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-email-verification-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
paths:
- 'email-verification-service/**'
- '.github/workflows/ci-email-verification-service.yml'
pull_request_target:
branches: [ main, dev ]
paths:
- 'email-verification-service/**'
- '.github/workflows/ci-email-verification-service.yml'
workflow_dispatch:

env:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-hello-world.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
paths:
- 'hello-world/**'
- '.github/workflows/ci-hello-world.yml'
pull_request_target:
branches: [ main, dev ]
paths:
- 'containers/hello-world/**'
- '.github/workflows/ci-hello-world.yml'
workflow_dispatch:

env:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-registry-avatar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
paths:
- 'citizen-registry/kubernetes/registry-avatar/**'
- '.github/workflows/ci-registry-avatar.yml'
pull_request_target:
branches: [ main, dev ]
paths:
- 'citizen-registry/kubernetes/registry-avatar/**'
- '.github/workflows/ci-registry-avatar.yml'
workflow_dispatch:

env:
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/ci-registry-gaia.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
paths:
- 'citizen-registry/kubernetes/registry-gaia/**'
- '.github/workflows/ci-registry-gaia.yml'
pull_request_target:
branches: [ main, dev ]
paths:
- 'citizen-registry/kubernetes/registry-gaia/**'
- '.github/workflows/ci-registry-gaia.yml'
workflow_dispatch:

env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ private void restoreEntryPoint(UUID connectionId, UUID threadId, Session session
Predicate predicate = builder.equal(root.get("birthdate"), session.getBirthdate());
allPredicates.add(predicate);
}
if (restoreBirthdateClaim) {
if (restoreBirthplaceClaim) {
Predicate predicate = builder.equal(root.get("placeOfBirth"), session.getPlaceOfBirth());
allPredicates.add(predicate);
}
Expand Down Expand Up @@ -1126,38 +1126,53 @@ private boolean identityAlreadyExists(Session session) {
if (restoreCitizenidClaim) {
Predicate predicate = builder.equal(root.get("citizenId"), session.getCitizenId());
allPredicates.add(predicate);
if (debug) logger.info("identityAlreadyExists: citizenId: " + session.getCitizenId());
}

if (restoreFirstnameClaim) {
Predicate predicate = builder.equal(root.get("firstname"), session.getFirstname());
allPredicates.add(predicate);

if (debug) logger.info("identityAlreadyExists: firstname: " + session.getFirstname());
}
if (restoreLastnameClaim) {
Predicate predicate = builder.equal(root.get("lastname"), session.getLastname());
allPredicates.add(predicate);
if (debug) logger.info("identityAlreadyExists: lastname: " + session.getLastname());
}
if (restoreAvatarnameClaim) {
Predicate predicate = builder.equal(root.get("avatarname"), session.getAvatarname());
allPredicates.add(predicate);
if (debug) logger.info("identityAlreadyExists: avatarname: " + session.getAvatarname());
}

if (restoreBirthdateClaim) {
Predicate predicate = builder.equal(root.get("birthdate"), session.getBirthdate());
allPredicates.add(predicate);
if (debug) logger.info("identityAlreadyExists: birthdate: " + session.getBirthdate());
}
if (restoreBirthdateClaim) {
if (restoreBirthplaceClaim) {
Predicate predicate = builder.equal(root.get("placeOfBirth"), session.getPlaceOfBirth());
allPredicates.add(predicate);
if (debug) logger.info("identityAlreadyExists: placeOfBirth: " + session.getPlaceOfBirth());
}

query.where(builder.and(allPredicates.toArray(new Predicate[allPredicates.size()])));

query.orderBy(builder.desc(root.get("id")));
Query q = em.createQuery(query);

Identity res = (Identity) q.getResultList().stream().findFirst().orElse(null);
List<Identity> founds = q.getResultList();
if (debug) {
try {
logger.info("identityAlreadyExists: found: " + JsonUtil.serialize(founds, false));
} catch (JsonProcessingException e) {
logger.error("", e);
}
}


return (res!=null);
return (founds.size()>0);

}

Expand Down Expand Up @@ -1457,7 +1472,7 @@ private void createEntryPoint(UUID connectionId, UUID threadId, Session session,
birthDate = LocalDate.from(df.parse(content));
session.setBirthdate(birthDate);
session.setCreateStep(getNextCreateStep(session.getCreateStep()));

session = em.merge(session);
} catch (Exception e) {
logger.error("", e);
mtProducer.sendMessage(TextMessage.build(connectionId, threadId, getMessage("BIRTHDATE_ERROR")));
Expand Down

0 comments on commit b07c761

Please sign in to comment.