feat: add user and role view sheets with detailed information display

- Created UserViewSheet component to display user details including username, full name, role, status, and timestamps.
- Created RoleViewSheet component to display role details including name, level, status, creation date, and associated permissions.
- Introduced permissions configuration in a new permissions.ts file, defining categories and permission codes for better management.
- Implemented middleware for authentication, ensuring access control for protected routes.
This commit is contained in:
Kalana B. Thilakarathna
2026-10-18 23:11:01 +05:30
parent 558afc6f9d
commit 0052725b88
86 changed files with 41117 additions and 939 deletions
+21 -5
View File
@@ -1,12 +1,10 @@
using Distribution.Features.Auth;
using Distribution.Infra.UoW;
using Microsoft.AspNetCore.Identity;
namespace Distribution.Features.User;
public class UserService(IUserRepository repo, IUnitOfWork uow)
public class UserService(IUserRepository repo, IUnitOfWork uow, IAuthHexClient authHex)
{
private readonly PasswordHasher<Models.User> _hasher = new();
private static UserResponse ToResponse(Models.User u) =>
new(u.Id, u.Username, u.FullName, u.FK_RoleId, u.Role?.Name ?? string.Empty,
u.FK_ReportsToUserId, u.IsActive, u.CreatedAt, u.UpdatedAt);
@@ -33,12 +31,30 @@ public class UserService(IUserRepository repo, IUnitOfWork uow)
FK_RoleId = request.RoleId,
FK_ReportsToUserId = request.ReportsToUserId
};
user.PasswordHash = _hasher.HashPassword(user, request.Password);
await uow.BeginAsync(ct);
try
{
await repo.AddAsync(user);
var authResult = await authHex.CallAsync("registerUser", new
{
userId = user.Id,
userName = request.Username,
email = request.Username,
fullname = request.FullName,
password = request.Password,
roleId = request.RoleId,
userTypeId = "00000001-0000-0000-0000-200000000000",
sendCredentialsEmail = false
}, reference: user.Id.ToString(), ct: ct);
if (!authResult.Success)
{
await uow.RollbackAsync(ct);
throw new InvalidOperationException($"AuthHex registration failed: {authResult.Message}");
}
await uow.CommitAsync(ct);
}
catch