From 368716d3ba636c540ad4f709475f4d987023028e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Fri, 17 Mar 2023 16:47:49 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B8=D0=B5=D0=BD=D1=82=D0=B0=20(regex)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConfectionaryBusinessLogic/ClientLogic.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ConfectionaryBusinessLogic/ClientLogic.cs b/ConfectionaryBusinessLogic/ClientLogic.cs index 1a9b6c8..be32b1f 100644 --- a/ConfectionaryBusinessLogic/ClientLogic.cs +++ b/ConfectionaryBusinessLogic/ClientLogic.cs @@ -1,10 +1,12 @@ -using ConfectioneryBusinessLogic.BusinessLogics; +using System.Text.RegularExpressions; +using ConfectioneryBusinessLogic.BusinessLogics; using ConfectioneryContracts.BindingModels; using ConfectioneryContracts.BusinessLogicsContracts; using ConfectioneryContracts.SearchModels; using ConfectioneryContracts.StoragesContract; using ConfectioneryContracts.ViewModels; using Microsoft.Extensions.Logging; +// ReSharper disable All namespace ConfectioneryBusinessLogic { @@ -102,6 +104,16 @@ namespace ConfectioneryBusinessLogic { throw new ArgumentNullException("Нет логина клиента", nameof(model.Email)); } + if (!Regex.IsMatch(model.Email, @"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$")) + { + throw new ArgumentException("Некорретно введенный email", nameof(model.Email)); + } + // Исходный: ^((\w+\d+\W+)|(\w+\W+\d+)|(\d+\w+\W+)|(\d+\W+\w+)|(\W+\w+\d+)|(\W+\d+\w +))+$ + // Просматриваем наперед последовательность (де-факто оператор &&) цифр, небуквенных символов и букв (не цифр и не пробельных символов) + if (!Regex.IsMatch(model.Password, @"^(?=.*\d)(?=.*\W)(?=.*[^\d\s]).+$")) + { + throw new ArgumentException("Некорректно введенный пароль. Пароль должен содержать хотя бы одну букву, цифру и не буквенный символ", nameof(model.Password)); + } _logger.LogInformation("Client. Id: {Id}, FIO: {fio}, email: {email}", model.Id, model.ClientFIO, model.Email ); var element = _clientStorage.GetElement(new ClientSearchModel {