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:
@@ -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 =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user