Induláskor átmenjen a middlewareon a bejelentkezéshez szükséges elemek
This commit is contained in:
@@ -12,30 +12,30 @@ namespace WorkFlowCheck.API.Controllers
|
|||||||
public class CheckListController : ControllerBase
|
public class CheckListController : ControllerBase
|
||||||
{
|
{
|
||||||
private ICheckListService _checkListService;
|
private ICheckListService _checkListService;
|
||||||
public CheckListController(ICheckListService checkListService)
|
public CheckListController(ICheckListService checkListService)
|
||||||
{
|
{
|
||||||
_checkListService = checkListService;
|
_checkListService = checkListService;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetDashboardInfo")]
|
[HttpGet("GetDashboardInfo")]
|
||||||
public async Task<ApiResponseDTO<DashboardDTO>> GetDashboardInfo()
|
public async Task<ApiResponseDTO<DashboardDTO>> GetDashboardInfo()
|
||||||
{
|
{
|
||||||
var retVal = new ApiResponseDTO<DashboardDTO>();
|
var retVal = new ApiResponseDTO<DashboardDTO>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
retVal.Data = await _checkListService.GetDashboardInfoAsync();
|
retVal.Data = await _checkListService.GetDashboardInfoAsync();
|
||||||
retVal.IsSuccess = true;
|
retVal.IsSuccess = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
retVal.IsSuccess = false;
|
retVal.IsSuccess = false;
|
||||||
retVal.Errors.Add("A műszerfal adatainak lekérése sikertelen.");
|
retVal.Errors.Add("A műszerfal adatainak lekérése sikertelen.");
|
||||||
Log.Error(ex, "GetDashboardInfo failed");
|
Log.Error(ex, "GetDashboardInfo failed");
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetCheckListHeader/{id}")]
|
[HttpGet("GetCheckListHeader/{id}")]
|
||||||
public async Task<ApiResponseDTO<CheckListHeaderDTO>> GetCheckListHeader(int id)
|
public async Task<ApiResponseDTO<CheckListHeaderDTO>> GetCheckListHeader(int id)
|
||||||
{
|
{
|
||||||
var retVal = new ApiResponseDTO<CheckListHeaderDTO>()
|
var retVal = new ApiResponseDTO<CheckListHeaderDTO>()
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ namespace WorkFlowCheck.Web.Middleware
|
|||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
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"];
|
var token = context.Request.Cookies["AuthToken"];
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(token) && ValidateToken(token, out var claims))
|
if (!string.IsNullOrEmpty(token) && ValidateToken(token, out var claims))
|
||||||
|
|||||||
@@ -13,27 +13,27 @@ namespace WorkFlowCheck.Web.Services
|
|||||||
{
|
{
|
||||||
public class CheckListService : BaseService, ICheckListService
|
public class CheckListService : BaseService, ICheckListService
|
||||||
{
|
{
|
||||||
public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
|
public CheckListService(HttpClient httpClient, IConfiguration configuration, IHttpContextAccessor httpContextAccessor) : base(httpClient, configuration, httpContextAccessor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public async Task<DashboardDTO> GetDashboardInfoAsync()
|
public async Task<DashboardDTO> GetDashboardInfoAsync()
|
||||||
{
|
{
|
||||||
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetDashboardInfo";
|
var endpoint = $"{_httpClient.BaseAddress}api/CheckList/GetDashboardInfo";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<DashboardDTO>>(endpoint);
|
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<DashboardDTO>>(endpoint);
|
||||||
if (response?.IsSuccess == true && response.Data != null)
|
if (response?.IsSuccess == true && response.Data != null)
|
||||||
{
|
{
|
||||||
return response.Data;
|
return response.Data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Error(ex, "GetDashboardInfoAsync failed");
|
Log.Error(ex, "GetDashboardInfoAsync failed");
|
||||||
}
|
}
|
||||||
return new DashboardDTO { GeneratedAt = DateTime.Now };
|
return new DashboardDTO { GeneratedAt = DateTime.Now };
|
||||||
}
|
}
|
||||||
public async Task<ApiResponseListDTO<List<CheckListHeaderDTO>>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest)
|
public async Task<ApiResponseListDTO<List<CheckListHeaderDTO>>> GetFilteredCheckListHeaderAsync(DataTablesRequest dataTablesRequest)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user