Added register params validation

This commit is contained in:
KharchenkoVladimir 2021-10-22 17:41:00 +05:00
parent 9fea1c94a6
commit 6b2c4a359b
2 changed files with 7 additions and 6 deletions

View File

@ -69,19 +69,19 @@ namespace AsbCloudInfrastructure.Services
public int Register(UserDto userDto)
{
if (userDto.Login.Length < 3)
if (userDto.Login is null || userDto.Login.Length is < 3 or > 50)
return -1;
if (userDto.Password.Length < 3)
if (userDto.Password is null || userDto.Password.Length is < 3 or > 50)
return -2;
if (userDto.Email.Length > 255)
if (userDto.Email?.Length > 255)
return -3;
if (userDto.Phone.Length > 50)
if (userDto.Phone?.Length > 50)
return -4;
if (userDto.Position.Length > 255)
if (userDto.Position?.Length > 255)
return -5;
var salt = GenerateSalt();

View File

@ -54,8 +54,9 @@ namespace AsbCloudWebApi.Controllers
}
/// <summary>
/// Регистрация пользователя. Доступна администратору
/// Отправить заявку на регистрацию. Заявка подтверждается администратором.
/// </summary>
/// <param name="user">Информация о новом пользователе</param>
/// <returns code="200">Ок</returns>
[HttpPost]
public IActionResult Register(UserDto user)