Decouple UserType, add Role entity and management

Removed all UserType logic and references, replacing them with a new Role model and management system. Introduced RoleManager service, repository, and API endpoint for role CRUD operations. Updated user flows and JWT claims to use RoleCode. Removed admin-only user CRUD endpoints. Updated DI, documentation, and error handling for consistency. Appsettings and DTOs now reflect the new role-based approach.
This commit is contained in:
Dhananjaya99
2026-10-19 12:57:07 +05:30
parent fbd079d337
commit 15832d1ae3
19 changed files with 393 additions and 297 deletions
+5 -11
View File
@@ -8,8 +8,8 @@ namespace AuthHex
{
public AppDBContext(DbContextOptions<AppDBContext> options) : base(options) { }
public DbSet<Models.User> Users => Set<Models.User>();
public DbSet<Models.UserType> UserType => Set<Models.UserType>();
public DbSet<Models.UserSession> UserSessions => Set<Models.UserSession>();
public DbSet<Models.Role> Roles => Set<Models.Role>();
public DbSet<Models.UserSession> UserSessions => Set<Models.UserSession>();
public DbSet<Models.Token> Token => Set<Models.Token>();
@@ -68,19 +68,13 @@ namespace AuthHex
.HasForeignKey(up => up.UserId)
.OnDelete(DeleteBehavior.Cascade);
// Configure UserType primary key
modelBuilder.Entity<Models.UserType>()
.HasKey(ut => ut.UserTypeId);
// Configure Role primary key
modelBuilder.Entity<Models.Role>()
.HasKey(r => r.RoleId);
// Configure User primary key and relationships
modelBuilder.Entity<Models.User>()
.HasKey(u => u.Id);
modelBuilder.Entity<Models.User>()
.HasOne(u => u.UserType)
.WithMany()
.HasForeignKey(u => u.UserTypeId)
.OnDelete(DeleteBehavior.Restrict);
}
}