Conditional Identity
This commit is contained in:
parent
817328f679
commit
cf98fd0a68
2 changed files with 20 additions and 3 deletions
22
Program.cs
22
Program.cs
|
|
@ -18,8 +18,13 @@ builder.Services.AddDbContext<ApplicationDbContext>(options =>
|
||||||
options.UseSqlite(connectionString));
|
options.UseSqlite(connectionString));
|
||||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||||
|
|
||||||
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
bool adminAuthenticate = builder.Configuration.GetValue("Admin:Authentication", true);
|
||||||
.AddEntityFrameworkStores<ApplicationDbContext>();
|
if (adminAuthenticate)
|
||||||
|
{
|
||||||
|
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true)
|
||||||
|
.AddEntityFrameworkStores<ApplicationDbContext>();
|
||||||
|
}
|
||||||
|
|
||||||
builder.Services.AddRazorPages();
|
builder.Services.AddRazorPages();
|
||||||
|
|
||||||
builder.Services.Configure<DhcpOptions>(builder.Configuration.GetRequiredSection("Dhcp"));
|
builder.Services.Configure<DhcpOptions>(builder.Configuration.GetRequiredSection("Dhcp"));
|
||||||
|
|
@ -64,7 +69,7 @@ else
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
if (app.Configuration.GetValue("Admin:Authentication", true))
|
if (adminAuthenticate)
|
||||||
{
|
{
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
}
|
}
|
||||||
|
|
@ -72,4 +77,15 @@ if (app.Configuration.GetValue("Admin:Authentication", true))
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.MapRazorPages();
|
app.MapRazorPages();
|
||||||
|
|
||||||
|
using (var scope = app.Services.CreateScope())
|
||||||
|
{
|
||||||
|
using var appDb = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
|
appDb.Database.Migrate();
|
||||||
|
|
||||||
|
if (adminAuthenticate)
|
||||||
|
{
|
||||||
|
/* TODO: Generate Admin Account if None found */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=PowerDNS/DHCP Companion Remote
|
Description=PowerDNS/DHCP Companion Remote
|
||||||
|
After=kea-dhcp.service
|
||||||
Before=pdns.service
|
Before=pdns.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue