32 lines
872 B
C#
32 lines
872 B
C#
using JwtAuthManager;
|
|
using JwtAuthManager.Models;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace AuthWebApi.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class AccountController : ControllerBase
|
|
{
|
|
private readonly JwtTokenHandler _jwtTokenHandler;
|
|
|
|
public AccountController(JwtTokenHandler jwtTokenHandler)
|
|
{
|
|
_jwtTokenHandler = jwtTokenHandler;
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult<AuthResponse?> Authenticate([FromBody] AuthRequest authRequest)
|
|
{
|
|
var authResponse = _jwtTokenHandler.GenerateJwtToken(authRequest);
|
|
if(authResponse == null) return Unauthorized();
|
|
return Ok(authResponse);
|
|
}
|
|
|
|
|
|
// https://localhost:7041/ApiTest post get
|
|
//https://localhost:7041/ApiTest/{id} delete
|
|
}
|
|
}
|