fix user controller (login)

This commit is contained in:
mfnefd 2024-06-06 17:52:35 +04:00
parent 5345098bbd
commit 2533ba90c0

View File

@ -21,11 +21,11 @@ namespace RestAPI.Controllers
}
[HttpPost]
public IResult Login([FromBody] UserBindingModel model)
public IResult Login(string email, string password)
{
try
{
var res = _userLogic.Login(model);
var res = _userLogic.Login(email, password);
return Results.Ok(res);
}
catch (ElementNotFoundException ex)
@ -50,17 +50,19 @@ namespace RestAPI.Controllers
{
try
{
var res = _userLogic.Login(model);
var res = _userLogic.Create(model);
return Results.Ok(res);
}
catch (AccountException ex)
{
_logger.LogWarning(ex, "Wrong registration data");
throw;
return Results.BadRequest(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error create user");
throw;
return Results.Problem(ex.Message);
}
}