From ab3b92ee3b8f9d2b2a2dfd737074ac25cace19de Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Tue, 6 Nov 2018 11:32:01 +0200 Subject: [PATCH 1/3] NY_4400: Access status verification implemented Signed-off-by: Stoyan Tzenkov --- src/main/java/biz/nynja/account/components/Validator.java | 2 -- .../biz/nynja/account/services/AccountServiceImpl.java | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/biz/nynja/account/components/Validator.java b/src/main/java/biz/nynja/account/components/Validator.java index 4dedb94..e78ab54 100644 --- a/src/main/java/biz/nynja/account/components/Validator.java +++ b/src/main/java/biz/nynja/account/components/Validator.java @@ -26,7 +26,6 @@ import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.Phonenumber; import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber; -import biz.nynja.account.grpc.AuthProviderDetails; import biz.nynja.account.grpc.AuthenticationType; import biz.nynja.account.grpc.CompletePendingAccountCreationRequest; import biz.nynja.account.grpc.ContactDetails; @@ -34,7 +33,6 @@ import biz.nynja.account.grpc.ContactType; import biz.nynja.account.grpc.CreatePendingAccountRequest; import biz.nynja.account.grpc.Date; import biz.nynja.account.grpc.DeleteAuthenticationProviderRequest; -import biz.nynja.account.grpc.DeleteContactInfoRequest; import biz.nynja.account.grpc.ErrorResponse.Cause; import biz.nynja.account.grpc.UpdateAccountRequest; import biz.nynja.account.grpc.UpdateProfileRequest; diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index f2edad9..5a8ae9e 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -6,6 +6,7 @@ package biz.nynja.account.services; import java.time.Instant; import java.util.Optional; import java.util.UUID; +import java.util.stream.Collectors; import org.apache.commons.lang3.tuple.ImmutablePair; import org.lognet.springboot.grpc.GRpcService; @@ -424,6 +425,12 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas logger.info("Complete pending account creation..."); logger.debug("Complete pending account creation...: {} ...", request); + if (request.getAccessStatus() == null) { + CompletePendingAccountCreationRequest newRequest = CompletePendingAccountCreationRequest.newBuilder(request) + .setAccessStatus(AccessStatus.ENABLED).build(); + request = newRequest; + } + Cause cause = validator.validateCompletePendingAccountCreationRequest(request); if (cause != null) { logAndBuildGrpcAccountResponse(responseObserver, AccountResponse.newBuilder(), "Validation failed", "", -- GitLab From 05ac6d9ce630de7ab97a15dec4f2b079e87cc999 Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Fri, 9 Nov 2018 12:48:48 +0200 Subject: [PATCH 2/3] NY-4400: Check moved to AccountRepositoryAdditionalImpl Signed-off-by: Stoyan Tzenkov --- .../repositories/AccountRepositoryAdditionalImpl.java | 7 ++++++- .../biz/nynja/account/services/AccountServiceImpl.java | 6 ------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 643a88d..076e151 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -30,6 +30,7 @@ import com.datastax.driver.core.Session; import biz.nynja.account.components.AccountServiceHelper; import biz.nynja.account.components.StatementsPool; import biz.nynja.account.components.Validator; +import biz.nynja.account.grpc.AccessStatus; import biz.nynja.account.grpc.CompletePendingAccountCreationRequest; import biz.nynja.account.grpc.UpdateAccountRequest; import biz.nynja.account.grpc.UpdateProfileRequest; @@ -145,7 +146,11 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio newAccount.setCreationTimestamp(creationTimestamp); newAccount.setQrCode(request.getQrCode()); newAccount.setRoles(request.getRolesList().stream().map(n -> n.toString()).collect(Collectors.toSet())); - newAccount.setAccessStatus(request.getAccessStatus().toString()); + if (request.getAccessStatus() == null) { + newAccount.setAccessStatus(AccessStatus.ENABLED.toString()); + } else { + newAccount.setAccessStatus(request.getAccessStatus().toString()); + } batchOps.insert(newAccount); } diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 5a8ae9e..77058b7 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -425,12 +425,6 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas logger.info("Complete pending account creation..."); logger.debug("Complete pending account creation...: {} ...", request); - if (request.getAccessStatus() == null) { - CompletePendingAccountCreationRequest newRequest = CompletePendingAccountCreationRequest.newBuilder(request) - .setAccessStatus(AccessStatus.ENABLED).build(); - request = newRequest; - } - Cause cause = validator.validateCompletePendingAccountCreationRequest(request); if (cause != null) { logAndBuildGrpcAccountResponse(responseObserver, AccountResponse.newBuilder(), "Validation failed", "", -- GitLab From f970bae4c598b9745a4fe37a455a3b5d56241e96 Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Fri, 9 Nov 2018 13:32:01 +0200 Subject: [PATCH 3/3] NY-4400: Just set AccessStatus to ENABLED Signed-off-by: Stoyan Tzenkov --- .../repositories/AccountRepositoryAdditionalImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 076e151..3254ff1 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -146,11 +146,7 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio newAccount.setCreationTimestamp(creationTimestamp); newAccount.setQrCode(request.getQrCode()); newAccount.setRoles(request.getRolesList().stream().map(n -> n.toString()).collect(Collectors.toSet())); - if (request.getAccessStatus() == null) { - newAccount.setAccessStatus(AccessStatus.ENABLED.toString()); - } else { - newAccount.setAccessStatus(request.getAccessStatus().toString()); - } + newAccount.setAccessStatus(AccessStatus.ENABLED.toString()); batchOps.insert(newAccount); } -- GitLab