Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

citizen-registry: fixed copy-paste error that prevented detecting an already created identity in some specific cases #16

Merged
merged 4 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading