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