Add role control
This commit is contained in:
@@ -23,6 +23,7 @@ public class AppDbContext : IdentityDbContext<AppUser, AppRole, string>
|
||||
public DbSet<Check> Checks => Set<Check>();
|
||||
public DbSet<CheckLine> CheckLines => Set<CheckLine>();
|
||||
public DbSet<MealAttendance> MealAttendances => Set<MealAttendance>();
|
||||
public DbSet<RolePermission> RolePermissions => Set<RolePermission>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
@@ -60,6 +61,18 @@ public class AppDbContext : IdentityDbContext<AppUser, AppRole, string>
|
||||
entity.Property(e => e.Description).HasMaxLength(500);
|
||||
});
|
||||
|
||||
// ── RolePermission (configurable RBAC matrix) ───────────────────────
|
||||
builder.Entity<RolePermission>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.Property(e => e.RoleId).HasMaxLength(450).IsRequired();
|
||||
entity.Property(e => e.Module).HasMaxLength(60).IsRequired();
|
||||
// One row per (role, module).
|
||||
entity.HasIndex(e => new { e.RoleId, e.Module }).IsUnique();
|
||||
entity.HasOne(e => e.Role).WithMany()
|
||||
.HasForeignKey(e => e.RoleId).OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
// ── FamilyUnit ──────────────────────────────────────────────────────
|
||||
builder.Entity<FamilyUnit>(entity =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user