using Microsoft.AspNetCore.Mvc; using TaxBaik.Web.Services; namespace TaxBaik.Web.Controllers; [ApiController] [Route("api/[controller]")] public class AuthController : ControllerBase { private readonly AuthService _authService; public AuthController(AuthService authService) { _authService = authService; } [HttpPost("login")] public async Task Login([FromBody] LoginRequest request) { if (string.IsNullOrWhiteSpace(request.Username) || string.IsNullOrWhiteSpace(request.Password)) return BadRequest(new { message = "Username and password are required" }); var token = await _authService.AuthenticateAndGenerateTokenAsync(request.Username, request.Password); if (token == null) return Unauthorized(new { message = "Invalid username or password" }); return Ok(new { token, expiresIn = 28800 }); } } public class LoginRequest { public string Username { get; set; } = string.Empty; public string Password { get; set; } = string.Empty; }