refactor: Remove ICurrentUserService dependency from query handlers and update user ID handling logic
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 8s
Build and Deploy to Kubernetes / build-and-deploy (push) Failing after 8s
This commit is contained in:
+4
-9
@@ -8,28 +8,23 @@ public class GetNetworkTreeQueryHandler : IRequestHandler<GetNetworkTreeQuery, N
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
private readonly ILogger<GetNetworkTreeQueryHandler> _logger;
|
||||
private readonly ICurrentUserService _currentUser;
|
||||
|
||||
public GetNetworkTreeQueryHandler(
|
||||
IApplicationDbContext context,
|
||||
ILogger<GetNetworkTreeQueryHandler> logger,
|
||||
ICurrentUserService currentUser)
|
||||
ILogger<GetNetworkTreeQueryHandler> logger)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<NetworkTreeDto?> Handle(GetNetworkTreeQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
// Get userId - use current user if UserId is 0
|
||||
var userId = request.UserId == 0
|
||||
? (long.TryParse(_currentUser.UserId, out var currentUserId) ? currentUserId : 0)
|
||||
: request.UserId;
|
||||
// UserId must be provided - customer endpoints resolve from JWT before calling
|
||||
var userId = request.UserId;
|
||||
|
||||
if (userId == 0)
|
||||
{
|
||||
throw new UnauthorizedAccessException("User ID not found");
|
||||
throw new ArgumentException("UserId is required for network tree query");
|
||||
}
|
||||
|
||||
// Create a new request with the resolved userId
|
||||
|
||||
Reference in New Issue
Block a user