Apigateway/AuthWebApi/Controllers/AccountController.cs

32 lines
872 B
C#
Raw Normal View History

2022-11-02 11:31:23 -05:00
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
}
}