Přemístění + dodělání funkčnosti webu.

This commit is contained in:
Matěj Kubíček
2026-09-17 17:50:48 +02:00
parent 3a35d10227
commit f223721fbd
128 changed files with 714 additions and 172 deletions
+15
View File
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using StuzkovakWeb.Entities;
namespace StuzkovakWeb.Data;
public class AppDbContext : IdentityDbContext<UserEntity>
{
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
}
public DbSet<InviteEntity> Invites { get; set; }
}
+33
View File
@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Identity;
using StuzkovakWeb.Entities;
namespace StuzkovakWeb.Data;
public static class DataSeeder
{
public static async Task SeedAsync(UserManager<UserEntity> userManager, RoleManager<IdentityRole> roleManager)
{
// Ensure roles exist
foreach (var role in new[] { "Admin", "User" })
{
if (!await roleManager.RoleExistsAsync(role))
await roleManager.CreateAsync(new IdentityRole(role));
}
// Seed initial admin user if none exists
if (!userManager.Users.Any())
{
var admin = new UserEntity
{
UserName = "admin",
Email = "admin@template.com",
EmailConfirmed = true,
};
// You should change this password on first login
var result = await userManager.CreateAsync(admin, "Admin123!");
if (result.Succeeded)
await userManager.AddToRoleAsync(admin, "Admin");
}
}
}