54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Oqtane.Infrastructure;
|
|
using System;
|
|
using SZUAbsolventenverein.Module.AdminModules.Models;
|
|
using SZUAbsolventenverein.Module.AdminModules.Repository;
|
|
using SZUAbsolventenverein.Module.AdminModules.Services;
|
|
using SZUAbsolventenverein.Module.AdminSettings.Services;
|
|
|
|
namespace SZUAbsolventenverein.Module.AdminModules.Startup
|
|
{
|
|
public class ServerStartup : IServerStartup
|
|
{
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
public void ConfigureMvc(IMvcBuilder mvcBuilder)
|
|
{
|
|
// not implemented
|
|
}
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddTransient<IAdminModulesService, ServerAdminModulesService>();
|
|
services.AddTransient<IAdminSettingsService, ServerAdminSettingsService>();
|
|
services.AddTransient<IAdminSettingsRepository, AdminSettingsRepository>();
|
|
services.AddDbContextFactory<AdminModulesContext>(opt => { }, ServiceLifetime.Transient);
|
|
|
|
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
|
{
|
|
options.TokenLifespan = TimeSpan.FromDays(2);
|
|
});
|
|
|
|
try
|
|
{
|
|
AdminSetting settings = AdminSettingsExtensions.LoadSettings();
|
|
services.Configure<DataProtectionTokenProviderOptions>(options =>
|
|
{
|
|
options.TokenLifespan = TimeSpan.FromDays(settings.TokenLifetime);
|
|
});
|
|
Console.WriteLine("Saving token lifetime: " + settings.TokenLifetime + " days");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|