Seeding, cleanup, fix nginx proxying

This commit is contained in:
lumijiez
2025-06-09 23:54:37 +03:00
parent c2c4b739f1
commit dd7eeb9eea
32 changed files with 439 additions and 240 deletions

View File

@@ -24,6 +24,8 @@ public static class Startup
services.AddScoped<IUserRepository, UserRepository>();
services.AddScoped<IUserRoleRepository, UserRoleRepository>();
services.AddScoped<IUnitOfWork, UnitOfWork>();
services.AddScoped<Seeder>();
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(
@@ -61,13 +63,14 @@ public static class Startup
if (string.IsNullOrEmpty(userId)) return Task.CompletedTask;
var identity = context.Principal!.Identity as ClaimsIdentity;
var roles = (from ur in dbContext?.UserRole
var roles = (
from ur in dbContext?.UserRole
join r in dbContext?.Roles on ur.RoleId equals r.Id
where ur.UserId == userId
select r.RoleName).ToList();
foreach (var role in roles) identity!.AddClaim(new Claim(ClaimTypes.Role, role));
identity!.AddClaim(new Claim(ClaimTypes.Role, "User"));
return Task.CompletedTask;
}
};