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
+15
View File
@@ -0,0 +1,15 @@
namespace AuthHex.Models
{
public class Role
{
public Guid RoleId { get; set; }
public string Code { get; set; } = string.Empty; // ADMIN, USER, STAFF
public string?Name { get; set; } = string.Empty;
public bool? IsSystemRole { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
}
+2 -7
View File
@@ -30,13 +30,8 @@ namespace AuthHex.Models
public bool IsMfaEnabled { get; set; }
public UserMfa? UserMfa { get; set; }
// Roles are not an authentication concern: the ERP owns a person's role and permissions (users.RoleId in ERPCore).
// AuthHex only says who the person is. (The old Users.RoleId column is left in the table, nullable and unmapped,
// until it is dropped - see Docs/migrations/2026-10-remove-roles.sql.)
public Guid UserTypeId { get; set; }
public UserType? UserType { get; set; }
//User Role and Type
public string? RoleCode { get; set; }
public ICollection<UserSession>? Sessions { get; set; }
public ICollection<UserProvider>? Providers { get; set; }
}
-13
View File
@@ -1,13 +0,0 @@
namespace AuthHex.Models
{
public class UserType
{
public Guid UserTypeId { get; set; }
public string Code { get; set; } = string.Empty; // INDIVIDUAL, MERCHANT, AGENT
public string? Description { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
}