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:
@@ -22,20 +22,12 @@ public class JwtTokenHelper
|
||||
|
||||
public async Task<string> GenerateToken(User user)
|
||||
{
|
||||
// Load the user's usertype if not already loaded. (No role: authorization belongs to the ERP, which reads the
|
||||
// person's role from its own tables - the token only says who the person is.)
|
||||
if (user.UserType == null)
|
||||
{
|
||||
await _dbContext.Entry(user)
|
||||
.Reference(u => u.UserType)
|
||||
.LoadAsync();
|
||||
}
|
||||
|
||||
var claims = new List<Claim>
|
||||
{
|
||||
new Claim("UserId", user.Id.ToString()),
|
||||
new Claim("UserTypeId", user.UserTypeId.ToString()),
|
||||
new Claim("UserTypeCode", user.UserType?.Code ?? ""),
|
||||
new Claim("RoleId", user.RoleCode ?? ""),
|
||||
new Claim("RoleCode", user.RoleCode ?? ""),
|
||||
|
||||
new Claim("NIC", user.Nic ?? ""),
|
||||
new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Iat,
|
||||
|
||||
Reference in New Issue
Block a user