Files
SIG-CM/src/SIGCM.API/Controllers/AuthController.cs

27 lines
662 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
using SIGCM.Application.DTOs;
using SIGCM.Application.Interfaces;
namespace SIGCM.API.Controllers;
[ApiController]
[Route("api/[controller]")]
public class AuthController : ControllerBase
{
private readonly IAuthService _authService;
public AuthController(IAuthService authService)
{
_authService = authService;
}
[HttpPost("login")]
public async Task<IActionResult> Login(LoginDto dto)
{
var token = await _authService.LoginAsync(dto.Username, dto.Password);
if (token == null) return Unauthorized("Invalid credentials");
return Ok(new { token });
}
}