using EnvelopeGenerator.Application.Contracts; using EnvelopeGenerator.Application.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Security.Claims; namespace EnvelopeGenerator.Web.Controllers.Test { [ApiController] [Route("api/test/[controller]")] public class TestAuthController : ControllerBase { private readonly IJWTService _authService; public TestAuthController(IJWTService authService) { _authService = authService; } [HttpPost] public IActionResult ProvideToken([FromQuery] string value) { var token = _authService.GenerateToken(value); return Ok(token); } [HttpGet] public IActionResult GetSecurityToken([FromQuery] string token) { var sToken = _authService.ReadSecurityToken(token); return Ok(sToken); } [HttpGet("Username")] [Authorize] public IActionResult Getname() { var username = User.Claims?.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value; return Ok(username); } } }