Fase 1: Inicialización del Backend .NET 10, Configuración de Dapper, Autenticación JWT y Entidades Base
This commit is contained in:
26
src/SIGCM.API/Controllers/AuthController.cs
Normal file
26
src/SIGCM.API/Controllers/AuthController.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user