Refines user creation email uniqueness check
Improves email duplicate detection by adding specific constraint name validation Prevents potential false positives in unique email constraint handling Ensures more precise exception handling for email registration
This commit is contained in:
parent
a991dcdb97
commit
e5e7c1c19f
1 changed files with 1 additions and 3 deletions
|
|
@ -14,8 +14,6 @@ namespace PlanTempus.Components.Users.Create
|
|||
{
|
||||
public async Task<CommandResponse> Handle(CreateUserCommand command)
|
||||
{
|
||||
command.TransactionId = Guid.NewGuid();
|
||||
|
||||
using var db = databaseOperations.CreateScope(nameof(CreateUserHandler));
|
||||
try
|
||||
{
|
||||
|
|
@ -41,7 +39,7 @@ namespace PlanTempus.Components.Users.Create
|
|||
|
||||
return new CommandResponse(command.CorrelationId, command.GetType().Name, command.TransactionId);
|
||||
}
|
||||
catch (PostgresException ex) when (ex.SqlState == "23505")
|
||||
catch (PostgresException ex) when (ex.SqlState == "23505" && ex.ConstraintName.Equals("users_email_key", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
db.Error(ex);
|
||||
throw new EmailAlreadyRegistreredException();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue