Skip to content

Commit

Permalink
fix updating verification for account (#376)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikewacker authored Jan 19, 2025
1 parent 35e82e1 commit 6337763
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ public CompletionStage<Optional<String>> trySave(String accountId, VerifiedUser
Optional<String> maybeConflictingAccountId = Optional.ofNullable(verifiedAccounts.get(user.getPseudonym()));
if (maybeConflictingAccountId.isPresent()) {
String conflictingAccountId = maybeConflictingAccountId.get();
VerificationState conflictingState = loadAndUpdate(conflictingAccountId);
if (conflictingState.getStatus() == VerificationStatus.VERIFIED) {
return CompletableFuture.completedFuture(Optional.of(conflictingAccountId));
if (!conflictingAccountId.equals(accountId)) {
VerificationState conflictingState = loadAndUpdate(conflictingAccountId);
if (conflictingState.getStatus() == VerificationStatus.VERIFIED) {
return CompletableFuture.completedFuture(Optional.of(conflictingAccountId));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ public void saveThenLoad() {
assertThat(state.getUser()).isEqualTo(user);
}

@Test
public void saveTwiceForSameAccount() {
VerifiedUser user = TestModels.createVerifiedUser();
Optional<String> maybeConflictingAccountId1 = getCompleted(store.trySave("username", user, expiresIn(5)));
assertThat(maybeConflictingAccountId1).isEmpty();

Optional<String> maybeConflictingAccountId2 = getCompleted(store.trySave("username", user, expiresIn(10)));
assertThat(maybeConflictingAccountId2).isEmpty();
}

@Test
public void loadUnverified() {
VerificationState state = getCompleted(store.load("username"));
Expand Down

0 comments on commit 6337763

Please sign in to comment.