From b6f8d96afe1878e7396c8a745c5dc44e95770c24 Mon Sep 17 00:00:00 2001 From: Sandertp Date: Thu, 29 Aug 2024 10:28:09 +0200 Subject: [PATCH] Add email validation check Co-authored-by: Reimar --- API/Application/Users/Commands/CreateUser.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/API/Application/Users/Commands/CreateUser.cs b/API/Application/Users/Commands/CreateUser.cs index 9954904..419ee62 100644 --- a/API/Application/Users/Commands/CreateUser.cs +++ b/API/Application/Users/Commands/CreateUser.cs @@ -16,6 +16,11 @@ namespace API.Application.Users.Commands public async Task> Handle(SignUpDTO signUpDTO) { + if (!new Regex(@".+@.+\..+").IsMatch(signUpDTO.Email)) + { + return new ConflictObjectResult(new{message = "Invalid email address."}); + } + List existingUsers = await _repository.QueryAllUsersAsync(); foreach (User existingUser in existingUsers)