- Enable UseAuthentication middleware.
- Fix variable typo from `postgreConnection` to `postgresConnection`. - Update `.gitignore` to exclude SQLite database files.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -86,3 +86,8 @@ API/app.db-shm
|
|||||||
# Vite build output
|
# Vite build output
|
||||||
GUI/dist/
|
GUI/dist/
|
||||||
wwwroot/
|
wwwroot/
|
||||||
|
|
||||||
|
# SQLite Datenbank-Dateien
|
||||||
|
*.db
|
||||||
|
*.db-shm
|
||||||
|
*.db-wal
|
||||||
@@ -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
|
||||||
|
|||||||
BIN
API/app.db
BIN
API/app.db
Binary file not shown.
Reference in New Issue
Block a user