This commit is contained in:
mmrbnjd
2024-04-18 00:33:46 +03:30
parent 3f3c283fef
commit fa5a83d8d3
7 changed files with 101 additions and 36 deletions

View File

@@ -7,6 +7,7 @@ using Shared.DTOs;
namespace Back.Controllers
{
[Route("api/[controller]")]
[Authorize]
[ApiController]
public class UserController : ControllerBase
{
@@ -19,12 +20,17 @@ namespace Back.Controllers
}
[HttpPost("authenticate")]
[AllowAnonymous]
public async Task<ActionResult<UserAuthenticationDTO>> Login(Authentication model)
public async Task<ActionResult<UserAuthenticationDTO>> Login([FromBody]Authentication model)
{
if (!ModelState.IsValid) return BadRequest(model);
var result = await _servUser.UserAuthentication(model.Username, model.Password);
if (result != null) return Ok(result);
else return NotFound("کاربری با این مشخصات یافت نشد");
}
[HttpGet("test")]
public async Task<ActionResult> test()
{
return Ok();