Update StartUP
This commit is contained in:
parent
1e37651335
commit
1bd1e342d3
@ -32,6 +32,7 @@ namespace phronCare.API.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
#region Segurity Endpoints
|
||||
[HttpPost]
|
||||
[Route("generate-qr-code")]
|
||||
public async Task<IActionResult> GenerateQRCodeAsync()
|
||||
@ -240,7 +241,7 @@ namespace phronCare.API.Controllers
|
||||
}
|
||||
return StatusCode(StatusCodes.Status500InternalServerError,"No se pudo encontrar el usuario, por favor intente nuevamente.");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region GenerateAccess
|
||||
private async Task<IActionResult> GenerateAccess(IdentityUser? user)
|
||||
{
|
||||
|
||||
@ -16,33 +16,34 @@ using Services.Interfaces;
|
||||
using System.Text;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// Asegúrate de que el archivo appsettings.json se cargue correctamente
|
||||
|
||||
#region AppSetting configuration
|
||||
// Asegurar que el archivo appsettings.json se cargue correctamente
|
||||
builder.Configuration.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
|
||||
#endregion
|
||||
|
||||
#region DbContext Identity Configuration
|
||||
#region DbContext Identity Configuration and Operational
|
||||
var configuration = builder.Configuration;
|
||||
builder.Services.AddDbContext<phronCareDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("phronCareDB")));
|
||||
builder.Services.AddDbContext<phronCareDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("phronCareDB"))); // DB Seguridad
|
||||
builder.Services.AddDbContext<PhronCareOperationsHubContext>(options =>
|
||||
options.UseSqlServer(configuration.GetConnectionString("PhronCareOperationsHubConnection")));
|
||||
options.UseSqlServer(configuration.GetConnectionString("PhronCareOperationsHubConnection"))); // DB Operacional
|
||||
|
||||
builder.Services.AddScoped<ITicketRepository, TicketRepository>();
|
||||
builder.Services.AddScoped<ITicketDom, TicketService>();
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#region Require Confirmed Email
|
||||
builder.Services.Configure<IdentityOptions>(
|
||||
opts => opts.SignIn.RequireConfirmedEmail = true
|
||||
);
|
||||
builder.Services.Configure<IdentityOptions>(opts => opts.SignIn.RequireConfirmedEmail = true);
|
||||
#endregion
|
||||
#region Identity EF Configuration
|
||||
|
||||
#region Security Identity EF Configuration
|
||||
builder.Services.AddIdentity<IdentityUser, IdentityRole>()
|
||||
.AddEntityFrameworkStores<phronCareDbContext>()
|
||||
.AddDefaultTokenProviders();
|
||||
#endregion
|
||||
|
||||
builder.Services.Configure<DataProtectionTokenProviderOptions>( opts => opts.TokenLifespan=TimeSpan.FromHours(10));
|
||||
builder.Services.AddSingleton<TwoFactorAuthenticator>();
|
||||
#endregion
|
||||
|
||||
#region Authentication Service
|
||||
|
||||
@ -80,7 +81,7 @@ builder.Services.AddSingleton(emailConfig);
|
||||
builder.Services.AddScoped<IEmailService, EmailService>();
|
||||
#endregion
|
||||
|
||||
#region Swagger Authorization
|
||||
#region Swagger Configuration
|
||||
builder.Services.AddSwaggerGen(option =>
|
||||
{
|
||||
option.SwaggerDoc("v1", new OpenApiInfo { Title = "phronCARE API - SaludLAB", Version = "v1" });
|
||||
@ -110,7 +111,7 @@ builder.Services.AddSwaggerGen(option =>
|
||||
});
|
||||
#endregion
|
||||
|
||||
#region CORS SIN CAMBIOS
|
||||
#region CORS sin cambios
|
||||
// builder.Services.AddCors(p => p.AddPolicy("CORS", builder =>
|
||||
// {
|
||||
// builder
|
||||
@ -156,4 +157,5 @@ app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseHttpsRedirection();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
Loading…
x
Reference in New Issue
Block a user