From 1e9cf09951bd4041f17a4f8580b74ed5d6f55394 Mon Sep 17 00:00:00 2001 From: "neha@quantoz" Date: Tue, 16 Apr 2024 11:27:27 +0200 Subject: [PATCH] Encoded email before sending it to Nexus --- .../Nexus/Repositories/NexusCustomerRepository.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs b/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs index a334ee0..bdab090 100644 --- a/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs +++ b/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs @@ -8,6 +8,7 @@ using Nexus.Sdk.Shared.Requests; using Nexus.Sdk.Token; using Nexus.Sdk.Token.Responses; +using stellar_dotnet_sdk; namespace Core.Infrastructure.Nexus.Repositories { @@ -31,14 +32,18 @@ public async Task CreateAsync(Customer customer, string? ip = null, Cancellation throw new CustomErrorsException(NexusErrorCodes.ExistingProperty.ToString(), customer.CustomerCode, Constants.NexusErrorMessages.ExistingCode); } + var encodedEmail = Uri.EscapeDataString(customer.Email.ToLower().Trim()); + var query = new Dictionary { - { "Email", customer.Email.ToLower().Trim() } + { "Email", encodedEmail } }; var existingCustomersWithEmail = await _tokenServer.Customers.Get(query); - if (existingCustomersWithEmail != null && existingCustomersWithEmail.Records.Any(existingCustomer => existingCustomer.Status != CustomerStatus.DELETED.ToString())) + if (existingCustomersWithEmail != null + && existingCustomersWithEmail.Records.Any() + && existingCustomersWithEmail.Records.Any(existingCustomer => existingCustomer.Status != CustomerStatus.DELETED.ToString())) { throw new CustomErrorsException(NexusErrorCodes.ExistingProperty.ToString(), customer.Email, Constants.NexusErrorMessages.ExistingEmail); }