feat: implement core radius service and database schema for guest access management
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using radiuscontroller.Components;
|
||||
using radiuscontroller.Data;
|
||||
using radiuscontroller.Services;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add database context
|
||||
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
||||
?? "Host=localhost;Port=5432;Database=radius;Username=radius;Password=radpass";
|
||||
|
||||
builder.Services.AddDbContext<RadiusDbContext>(options =>
|
||||
options.UseNpgsql(connectionString));
|
||||
|
||||
// Add services
|
||||
builder.Services.AddScoped<IRadiusService, RadiusService>();
|
||||
builder.Services.AddScoped<AdminAuthService>();
|
||||
|
||||
// Add Razor components
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Auto-seed admin user and default settings if DB available
|
||||
using (var scope = app.Services.CreateScope())
|
||||
{
|
||||
var radiusService = scope.ServiceProvider.GetRequiredService<IRadiusService>();
|
||||
await radiusService.EnsureDatabaseCreatedAndSeededAsync();
|
||||
}
|
||||
|
||||
// Configure HTTP request pipeline
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Error", createScopeForErrors: true);
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseAntiforgery();
|
||||
|
||||
app.MapStaticAssets();
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user