Fixed up the database connection, added admin account and admin area

This commit is contained in:
Matěj Kubíček
2026-04-18 18:47:58 +02:00
parent f50bec167f
commit 982093ff7a
20 changed files with 425 additions and 14 deletions
+27
View File
@@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
using TemplateWeb.Models.DbModels;
namespace TemplateWeb.Data;
public static class DataSeeder
{
public static async Task SeedAdminUser(AppDbContext context)
{
// Only run if no users exist
if (await context.Users.AnyAsync())
{
return;
}
var admin = new UserModel
{
UserName = "admin",
Email = "admin@template.com",
Password = BCrypt.Net.BCrypt.HashPassword("Admin123!"), // You should change this on first login
Role = UserRole.Admin
};
await context.Users.AddAsync(admin);
await context.SaveChangesAsync();
}
}