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
@@ -53,7 +53,7 @@ public class RecoveryManagerService
if (string.IsNullOrEmpty(identifier))
throw new ArgumentException("Identifier is required.");
var user = await _userRepository.GetUserByIdentifierAndType(identifier, null);
var user = await _userRepository.GetUserByIdentifierAndType(identifier);
if (user == null)
throw new KeyNotFoundException("No user found with the provided identifier.");
@@ -119,9 +119,14 @@ public class RecoveryManagerService
return new
{
ReferenceNumber = recovery.RecoveryReferenceNum,
ExpiresAt = recovery.ExpirationTime,
RecoveryType = "ResetLink"
Success = true,
Message = "Password reset link sent to your email.",
Data = new
{
ReferenceNumber = recovery.RecoveryReferenceNum,
ExpiresAt = recovery.ExpirationTime,
RecoveryType = "ResetLink"
}
};
}
else
@@ -171,9 +176,14 @@ public class RecoveryManagerService
return new
{
ReferenceNumber = recovery.RecoveryReferenceNum,
ExpiresAt = recovery.ExpirationTime,
RecoveryType = "OTP"
Success = true,
Message = "OTP sent successfully.",
Data = new
{
ReferenceNumber = recovery.RecoveryReferenceNum,
ExpiresAt = recovery.ExpirationTime,
RecoveryType = "OTP"
}
};
}
}
@@ -227,9 +237,14 @@ public class RecoveryManagerService
return new
{
ReferenceNumber = recovery.RecoveryReferenceNum,
UserId = recovery.UserId,
Verified = true
Success = true,
Message = "OTP verified successfully. You can now reset your password.",
Data = new
{
ReferenceNumber = recovery.RecoveryReferenceNum,
UserId = recovery.UserId,
Verified = true
}
};
}
catch
@@ -328,9 +343,14 @@ public class RecoveryManagerService
return new
{
UserId = user.Id,
Email = user.Email,
ResetAt = DateTime.UtcNow
Success = true,
Message = "Password reset successful. Please login with your new password.",
Data = new
{
UserId = user.Id,
Email = user.Email,
ResetAt = DateTime.UtcNow
}
};
}
catch
@@ -421,9 +441,14 @@ public class RecoveryManagerService
return new
{
UserId = user.Id,
Email = user.Email,
ResetAt = DateTime.UtcNow
Success = true,
Message = "Password reset successful. Please login with your new password.",
Data = new
{
UserId = user.Id,
Email = user.Email,
ResetAt = DateTime.UtcNow
}
};
}
catch