40 lines
1001 B
C#
40 lines
1001 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]")]
|
|
[Authorize]
|
|
[ApiController]
|
|
public class UserController : ControllerBase
|
|
{
|
|
private readonly servUser _servUser;
|
|
public UserController(servUser servUser)
|
|
{
|
|
|
|
_servUser = servUser;
|
|
|
|
}
|
|
[HttpPost("authenticate")]
|
|
[AllowAnonymous]
|
|
public async Task<ActionResult<UserAuthenticationDTO>> Login([FromBody]Authentication 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();
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|