feat: services, jwt auth, and api controllers

- LeadService with 15 SP calls (CRUD, actividades, pagos, montos)
- UsuarioService for login and profile queries
- JwtService for token generation with claims
- AuthController (login, perfil) with HttpOnly cookie
- LeadController (CRUD, actividades, estado, pago, contacto)
- Registered all services in DI (Program.cs)
This commit is contained in:
2026-07-07 17:56:25 -04:00
parent 3d5419403d
commit aed251d82f
7 changed files with 445 additions and 15 deletions
+10
View File
@@ -5,6 +5,7 @@ using Microsoft.IdentityModel.Tokens;
using Ventas.Infrastructure.Data;
using Ventas.Infrastructure.Repositories;
using Ventas.Core.Interfaces;
using Ventas.Services;
var builder = WebApplication.CreateBuilder(args);
@@ -21,7 +22,16 @@ builder.Services.AddScoped<ILeadRepository>(sp =>
builder.Services.AddScoped<ILeadQueryRepository>(sp =>
new LeadQueryRepository(connectionString));
builder.Services.AddScoped<LeadService>(sp =>
new LeadService(connectionString));
builder.Services.AddScoped<UsuarioService>(sp =>
new UsuarioService(connectionString));
var jwtSecret = builder.Configuration["Jwt:Secret"] ?? "default-dev-secret-change-in-production";
var jwtExpiration = int.Parse(builder.Configuration["Jwt:ExpirationMinutes"] ?? "30");
builder.Services.AddScoped<JwtService>(sp =>
new JwtService(jwtSecret, jwtExpiration));
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{