- Enable UseAuthentication middleware.
- Fix variable typo from `postgreConnection` to `postgresConnection`. - Update `.gitignore` to exclude SQLite database files.
This commit is contained in:
@@ -18,18 +18,19 @@ builder.Services.AddSwaggerGen();
|
||||
|
||||
// Authentication
|
||||
builder.Services.AddAuthorization();
|
||||
builder.Services.AddAuthentication().AddCookie(IdentityConstants.ApplicationScheme);
|
||||
builder.Services.AddAuthentication()
|
||||
.AddCookie(IdentityConstants.ApplicationScheme);
|
||||
|
||||
builder.Services.AddIdentityCore<User>()
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>()
|
||||
.AddApiEndpoints();
|
||||
|
||||
// Database
|
||||
var postgreConnection = builder.Configuration.GetConnectionString("PostgresConnection");
|
||||
if (!string.IsNullOrEmpty(postgreConnection))
|
||||
var postgresConnection = builder.Configuration.GetConnectionString("PostgresConnection");
|
||||
if (!string.IsNullOrEmpty(postgresConnection))
|
||||
{
|
||||
// Nutze PostgresSQL
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(postgreConnection));
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(postgresConnection));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -64,7 +65,7 @@ app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
// Map Auth Endpoints
|
||||
|
||||
BIN
API/app.db
BIN
API/app.db
Binary file not shown.
Reference in New Issue
Block a user