added login and password check

This commit is contained in:
Калышев Ян 2023-05-08 14:46:42 -07:00
parent acf4dec626
commit 0e15f8ffa5

View File

@ -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 BlacksmithWorkshopBusinessLogic.BusinessLogics
@ -103,6 +104,15 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
{
throw new ArgumentNullException("Нет пароля учетной записи клиента", nameof(model.ClientFIO));
}
if (!Regex.IsMatch(model.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", RegexOptions.IgnoreCase))
{
throw new ArgumentException("Некорректная адрес электронной почты", 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]*$")
|| model.Password.Length < 10 || model.Password.Length > 50)
{
throw new ArgumentException("Некорректный пароль", nameof(model.Password));
}
_logger.LogInformation("Client. ClientFIO:{ClientFIO}. Email:{Email}. Password:{Password}. Id:{Id}", model.ClientFIO, model.Email, model.Password, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel
{