You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
753 B
28 lines
753 B
using AspNetCoreApi.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace AspNetCoreApi.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("[controller]")]
|
|
public class AuthController : ControllerBase
|
|
{
|
|
private readonly JWTAuthenticationService _service;
|
|
|
|
public AuthController(JWTAuthenticationService service)
|
|
{
|
|
_service = service;
|
|
}
|
|
|
|
[HttpPost("authenticate")]
|
|
public async Task<IActionResult> Authenticate(string username, string password)
|
|
{
|
|
var token = await _service.Authenticate(username, password);
|
|
if (token == null)
|
|
{
|
|
return Unauthorized();
|
|
}
|
|
return Ok(new { Token = token });
|
|
}
|
|
}
|
|
}
|
|
|