From 53b8b71f899c8eb53c2204452916a7abfe1ead45 Mon Sep 17 00:00:00 2001 From: VictoriaPresnyakova Date: Sun, 30 Apr 2023 19:23:52 +0400 Subject: [PATCH] client edited: added check --- .../BusinessLogics/ClientLogic.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/JewelryStoreBusinessLogic/BusinessLogics/ClientLogic.cs b/JewelryStoreBusinessLogic/BusinessLogics/ClientLogic.cs index 7f53193..1e034ae 100644 --- a/JewelryStoreBusinessLogic/BusinessLogics/ClientLogic.cs +++ b/JewelryStoreBusinessLogic/BusinessLogics/ClientLogic.cs @@ -9,6 +9,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; namespace JewelryStoreBusinessLogic.BusinessLogics @@ -108,7 +109,16 @@ namespace JewelryStoreBusinessLogic.BusinessLogics { throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password)); } - _logger.LogInformation("Client. ClientFIO: {ClientFIO}. Email: {Email}. Id: {Id}", model.ClientFIO, model.Email, model.Id); + if (!Regex.IsMatch(model.Email, @"^[^@\s]+@[^@\s]+\.[^@\s]+$", RegexOptions.IgnoreCase)) + { + throw new ArgumentException("Неправильно введенный email", nameof(model.Email)); + } + + if (!Regex.IsMatch(model.Password, @"^^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w+))[\w\d\W]*$", RegexOptions.IgnoreCase)) + { + throw new ArgumentException("Неправильно введенный пароль", nameof(model.Password)); + } + _logger.LogInformation("Client. ClientFIO: {ClientFIO}. Email: {Email}. Id: {Id}", model.ClientFIO, model.Email, model.Id); var element = _clientStorage.GetElement(new ClientSearchModel { Email = model.Email