...
This commit is contained in:
38
Back/Controllers/UserController.cs
Normal file
38
Back/Controllers/UserController.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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("کاربری با این مشخصات یافت نشد");
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user