- Enable UseAuthentication middleware.

- Fix variable typo from `postgreConnection` to `postgresConnection`.
- Update `.gitignore` to exclude SQLite database files.
This commit is contained in:
2026-01-23 21:52:20 +01:00
parent 534ec5f36f
commit e0ecdad408
3 changed files with 12 additions and 6 deletions

7
.gitignore vendored
View File

@@ -85,4 +85,9 @@ API/app.db-shm
# Vite build output # Vite build output
GUI/dist/ GUI/dist/
wwwroot/ wwwroot/
# SQLite Datenbank-Dateien
*.db
*.db-shm
*.db-wal

View File

@@ -18,18 +18,19 @@ builder.Services.AddSwaggerGen();
// Authentication // Authentication
builder.Services.AddAuthorization(); builder.Services.AddAuthorization();
builder.Services.AddAuthentication().AddCookie(IdentityConstants.ApplicationScheme); builder.Services.AddAuthentication()
.AddCookie(IdentityConstants.ApplicationScheme);
builder.Services.AddIdentityCore<User>() builder.Services.AddIdentityCore<User>()
.AddEntityFrameworkStores<ApplicationDbContext>() .AddEntityFrameworkStores<ApplicationDbContext>()
.AddApiEndpoints(); .AddApiEndpoints();
// Database // Database
var postgreConnection = builder.Configuration.GetConnectionString("PostgresConnection"); var postgresConnection = builder.Configuration.GetConnectionString("PostgresConnection");
if (!string.IsNullOrEmpty(postgreConnection)) if (!string.IsNullOrEmpty(postgresConnection))
{ {
// Nutze PostgresSQL // Nutze PostgresSQL
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(postgreConnection)); builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(postgresConnection));
} }
else else
{ {
@@ -64,7 +65,7 @@ app.UseDefaultFiles();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization(); app.UseAuthorization();
// Map Auth Endpoints // Map Auth Endpoints

Binary file not shown.