Skip to content

Commit

Permalink
Encoded email before sending it to Nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
nagarwal4 committed Apr 16, 2024
1 parent 9e183f7 commit 1e9cf09
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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<string, string>
{
{ "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);
}
Expand Down

0 comments on commit 1e9cf09

Please sign in to comment.