From e430c36b038005d63f6eb58bbbc79d6e0d15d7d7 Mon Sep 17 00:00:00 2001 From: nagarwal4 <107046041+nagarwal4@users.noreply.github.com> Date: Tue, 16 Apr 2024 11:38:26 +0200 Subject: [PATCH] Encode email before sending it to Nexus (#80) * Encoded email before sending it to Nexus * Removed unused ref --- .../Nexus/Repositories/NexusCustomerRepository.cs | 8 ++++++-- 1 file changed, 6 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..4d39e6f 100644 --- a/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs +++ b/backend/core/src/Core.Infrastructure/Nexus/Repositories/NexusCustomerRepository.cs @@ -31,14 +31,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); }