Verbesserung der Benutzeroberfläche und Funktionalität des Sprachauswahl-Dropdown-Menüs
This commit is contained in:
@@ -23,7 +23,9 @@ try
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>() ??
|
||||
var config = builder.Configuration;
|
||||
|
||||
var allowedOrigins = config.GetSection("AllowedOrigins").Get<string[]>() ??
|
||||
throw new InvalidOperationException("AllowedOrigins section is missing in the configuration.");
|
||||
|
||||
builder.Services.AddCors(options =>
|
||||
@@ -53,18 +55,21 @@ try
|
||||
//remove option for Test*Controller
|
||||
options.Conventions.Add(new RemoveIfControllerConvention()
|
||||
.AndIf(c => c.ControllerName.StartsWith("Test"))
|
||||
.AndIf(c => !builder.Configuration.GetValue<bool>("AddTestControllers")));
|
||||
.AndIf(c => !config.GetValue<bool>("EnableTestControllers")));
|
||||
}).AddJsonOptions(q =>
|
||||
{
|
||||
// Prevents serialization error when serializing SvgBitmap in EnvelopeReceiver
|
||||
q.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||
});
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
if (config.GetValue<bool>("EnableSwagger"))
|
||||
{
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
}
|
||||
|
||||
//AddEF Core dbcontext
|
||||
var connStr = builder.Configuration["Config:ConnectionString"];
|
||||
var connStr = config["Config:ConnectionString"];
|
||||
builder.Services.AddDbContext<EGDbContext>(options =>
|
||||
options.UseSqlServer(connStr));
|
||||
|
||||
@@ -85,7 +90,6 @@ try
|
||||
builder.Services.AddScoped<IReceiverRepository, ReceiverRepository>();
|
||||
builder.Services.AddScoped<IUserReceiverRepository, UserReceiverRepository>();
|
||||
builder.Services.AddScoped<IEmailOutRepository, EmailOutRepository>();
|
||||
|
||||
builder.Services.AddScoped<IConfigService, ConfigService>();
|
||||
builder.Services.AddScoped<IDocumentReceiverElementService, DocumentReceiverElementService>();
|
||||
builder.Services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
|
||||
@@ -147,7 +151,7 @@ try
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton(_ => builder.Configuration.GetSection("ContactLink").Get<ContactLink>() ?? new ContactLink());
|
||||
builder.Services.AddSingleton(_ => config.GetSection("ContactLink").Get<ContactLink>() ?? new ContactLink());
|
||||
|
||||
builder.Services.AddCookieConsentSettings();
|
||||
|
||||
@@ -172,13 +176,16 @@ try
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
if (config.GetValue<bool>("EnableSwagger"))
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
var csp = builder.Configuration["Content-Security-Policy"];
|
||||
var csp = config["Content-Security-Policy"];
|
||||
if(csp is not null)
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
@@ -193,12 +200,13 @@ try
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
var languages = builder.Configuration.GetSection("Languages").Get<string[]>() ??
|
||||
var languages = config.GetSection("Languages").Get<string[]>() ??
|
||||
throw new InvalidOperationException("Languages section is missing in the configuration.");
|
||||
if(languages.Length == 0)
|
||||
throw new InvalidOperationException("There is no languages in languages section.");
|
||||
|
||||
app.UseCookieBasedLocalizer(languages);
|
||||
if(!config.GetValue<bool>("DisableMultiLanguage"))
|
||||
app.UseCookieBasedLocalizer(languages);
|
||||
|
||||
app.UseCors("SameOriginPolicy");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user