Fase 1: Inicialización del Backend .NET 10, Configuración de Dapper, Autenticación JWT y Entidades Base

This commit is contained in:
2025-12-17 13:08:21 -03:00
parent 15305c681c
commit eda016f93f
33 changed files with 819 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using SIGCM.Application.Interfaces;
using SIGCM.Domain.Interfaces;
namespace SIGCM.Infrastructure.Services;
public class AuthService : IAuthService
{
private readonly IUserRepository _userRepo;
private readonly ITokenService _tokenService;
public AuthService(IUserRepository userRepo, ITokenService tokenService)
{
_userRepo = userRepo;
_tokenService = tokenService;
}
public async Task<string?> LoginAsync(string username, string password)
{
var user = await _userRepo.GetByUsernameAsync(username);
if (user == null) return null;
bool valid = BCrypt.Net.BCrypt.Verify(password, user.PasswordHash);
if (!valid) return null;
return _tokenService.GenerateToken(user);
}
}