client edited: added check

This commit is contained in:
VictoriaPresnyakova 2023-04-30 19:23:52 +04:00
parent d90a87c05f
commit 53b8b71f89

View File

@ -9,6 +9,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace JewelryStoreBusinessLogic.BusinessLogics namespace JewelryStoreBusinessLogic.BusinessLogics
@ -108,7 +109,16 @@ namespace JewelryStoreBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password)); 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 var element = _clientStorage.GetElement(new ClientSearchModel
{ {
Email = model.Email Email = model.Email