From 3c8cab03ff0959827aaa6823409ac09a6c924ed9 Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Thu, 15 Nov 2018 14:09:39 +0200 Subject: [PATCH] NY-5328: Normalized phone before deletion if type is PHONE Signed-off-by: Stoyan Tzenkov --- src/main/java/biz/nynja/account/components/Validator.java | 2 +- .../java/biz/nynja/account/services/AccountServiceImpl.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/biz/nynja/account/components/Validator.java b/src/main/java/biz/nynja/account/components/Validator.java index fcf8b0c..4100ff2 100644 --- a/src/main/java/biz/nynja/account/components/Validator.java +++ b/src/main/java/biz/nynja/account/components/Validator.java @@ -129,7 +129,7 @@ public class Validator { case MISSING_TYPE: return Cause.MISSING_AUTH_PROVIDER_TYPE; case PHONE: - // We expect to receive phone number in the following format : ":" + // We expect to receive phone number in the following format : ":" String[] provider = authProvider.split(":"); if (provider == null || provider.length != 2) { return Cause.PHONE_NUMBER_INVALID; diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index e2cbdd8..0e612e9 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -656,6 +656,11 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas AuthenticationProvider authenticationProviderToDelete = AuthenticationProvider .createAuthenticationProviderFromProto(request.getAuthenticationProvider()); + if (request.getAuthenticationProvider().getAuthenticationType() == AuthenticationType.PHONE) { + authenticationProviderToDelete.setValue(phoneNumberValidator + .getNormalizedPhoneNumber(request.getAuthenticationProvider().getAuthenticationProvider())); + } + boolean removedFromObject = profile.removeAuthenticationProvider(authenticationProviderToDelete); if(!removedFromObject) { logAndBuildGrpcStatusResponse(responseObserver, StatusResponse.newBuilder(), "Authentication provider {} is not used by this profile.", -- GitLab