Skip to content

Commit

Permalink
Encode email before sending it to Nexus (#80)
Browse files Browse the repository at this point in the history
* Encoded email before sending it to Nexus

* Removed unused ref
  • Loading branch information
nagarwal4 authored and raymens committed Jun 25, 2024
1 parent 75d190f commit e430c36
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<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 e430c36

Please sign in to comment.