39 lines
922 B
C#
39 lines
922 B
C#
![]() |
using Back.Services;
|
|||
|
using Microsoft.AspNetCore.Authorization;
|
|||
|
using Microsoft.AspNetCore.Http;
|
|||
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
using Shared.DTOs;
|
|||
|
|
|||
|
namespace Back.Controllers
|
|||
|
{
|
|||
|
[Route("api/[controller]")]
|
|||
|
[ApiController]
|
|||
|
public class UserController : ControllerBase
|
|||
|
{
|
|||
|
private readonly servUser _servUser;
|
|||
|
public UserController(servUser servUser)
|
|||
|
{
|
|||
|
|
|||
|
_servUser = servUser;
|
|||
|
|
|||
|
}
|
|||
|
[HttpPost("authenticate")]
|
|||
|
[AllowAnonymous]
|
|||
|
public async Task<ActionResult<UserAuthenticationDTO>> Login(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("کاربری با این مشخصات یافت نشد");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
}
|