User synchronization revamped.
This commit is contained in:
@ -14,6 +14,7 @@ using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.RateLimiting;
|
||||
|
||||
namespace MessengerApi.Api
|
||||
@ -43,7 +44,7 @@ namespace MessengerApi.Api
|
||||
builder.Services.AddSingleton<ILogger>(new Factories.LoggerFactory(configuration).CreateLogger());
|
||||
builder.Services.AddSingleton<SendEndpointHandler>();
|
||||
builder.Services.AddSingleton<HousekeepingHandler>();
|
||||
builder.Services.AddSingleton<UserSetupHandler>();
|
||||
builder.Services.AddSingleton<UserConfigHandler>();
|
||||
builder.Services.AddSingleton<IDbContextFactory, DbContextFactory>();
|
||||
|
||||
builder.Services.AddScoped<Timing>();
|
||||
@ -142,9 +143,13 @@ namespace MessengerApi.Api
|
||||
}
|
||||
|
||||
// User synchronization
|
||||
var userSetupHandler = app.Services.GetRequiredService<UserSetupHandler>();
|
||||
userSetupHandler.UpdateFromFile(new FileInfo(Constants.USERFILE_FILENAME)).GetAwaiter().GetResult();
|
||||
|
||||
if (configuration.UsersConfig != null)
|
||||
{
|
||||
app.Services.GetRequiredService<ILogger>().Info($"Running userconfig synchronization for {configuration.UsersConfig.FullName}.");
|
||||
var handler = app.Services.GetRequiredService<UserConfigHandler>();
|
||||
handler.UpdateFromFile(configuration.UsersConfig).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
|
||||
Reference in New Issue
Block a user