Induláskor átmenjen a middlewareon a bejelentkezéshez szükséges elemek

This commit is contained in:
2026-09-16 14:02:18 +02:00
parent 364c1b455d
commit a6af9f2db7
3 changed files with 55 additions and 45 deletions
@@ -12,30 +12,30 @@ namespace WorkFlowCheck.API.Controllers
public class CheckListController : ControllerBase
{
private ICheckListService _checkListService;
public CheckListController(ICheckListService checkListService)
{
_checkListService = checkListService;
}
[HttpGet("GetDashboardInfo")]
public async Task<ApiResponseDTO<DashboardDTO>> GetDashboardInfo()
{
var retVal = new ApiResponseDTO<DashboardDTO>();
try
{
retVal.Data = await _checkListService.GetDashboardInfoAsync();
retVal.IsSuccess = true;
}
catch (Exception ex)
{
retVal.IsSuccess = false;
retVal.Errors.Add("A műszerfal adatainak lekérése sikertelen.");
Log.Error(ex, "GetDashboardInfo failed");
}
return retVal;
}
[HttpGet("GetCheckListHeader/{id}")]
public CheckListController(ICheckListService checkListService)
{
_checkListService = checkListService;
}
[HttpGet("GetDashboardInfo")]
public async Task<ApiResponseDTO<DashboardDTO>> GetDashboardInfo()
{
var retVal = new ApiResponseDTO<DashboardDTO>();
try
{
retVal.Data = await _checkListService.GetDashboardInfoAsync();
retVal.IsSuccess = true;
}
catch (Exception ex)
{
retVal.IsSuccess = false;
retVal.Errors.Add("A műszerfal adatainak lekérése sikertelen.");
Log.Error(ex, "GetDashboardInfo failed");
}
return retVal;
}
[HttpGet("GetCheckListHeader/{id}")]
public async Task<ApiResponseDTO<CheckListHeaderDTO>> GetCheckListHeader(int id)
{
var retVal = new ApiResponseDTO<CheckListHeaderDTO>()
@@ -19,6 +19,16 @@ namespace WorkFlowCheck.Web.Middleware
public async Task Invoke(HttpContext context)
{
var pathignore = context.Request.Path;
if (pathignore.StartsWithSegments("/css") ||
pathignore.StartsWithSegments("/js") ||
pathignore.StartsWithSegments("/lib") ||
pathignore.StartsWithSegments("/images") ||
pathignore.StartsWithSegments("/favicon.ico"))
{
await _next(context);
return;
}
var token = context.Request.Cookies["AuthToken"];
if (!string.IsNullOrEmpty(token) && ValidateToken(token, out var claims))
@@ -13,27 +13,27 @@ namespace WorkFlowCheck.Web.Services
{
public class CheckListService : BaseService, ICheckListService
{
public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
{
}
public async Task<DashboardDTO> GetDashboardInfoAsync()
{
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetDashboardInfo";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<DashboardDTO>>(endpoint);
if (response?.IsSuccess == true && response.Data != null)
{
return response.Data;
}
}
catch (Exception ex)
{
Log.Error(ex, "GetDashboardInfoAsync failed");
}
return new DashboardDTO { GeneratedAt = DateTime.Now };
}
public async Task<ApiResponseListDTO<List<CheckListHeaderDTO>>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest)
public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
{
}
public async Task<DashboardDTO> GetDashboardInfoAsync()
{
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetDashboardInfo";
try
{
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<DashboardDTO>>(endpoint);
if (response?.IsSuccess == true && response.Data != null)
{
return response.Data;
}
}
catch (Exception ex)
{
Log.Error(ex, "GetDashboardInfoAsync failed");
}
return new DashboardDTO { GeneratedAt = DateTime.Now };
}
public async Task<ApiResponseListDTO<List<CheckListHeaderDTO>>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest)
{
try
{