Fix DrillFlowChartController autorization.

Fix DrillFlowChartController.GetByTelemetryAsync() assertion
This commit is contained in:
Фролов 2021-10-14 16:16:35 +05:00
parent 91878bda5c
commit 2173f6593f

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using AsbCloudApp.Data;
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
namespace AsbCloudWebApi.Controllers
{
@ -12,6 +13,7 @@ namespace AsbCloudWebApi.Controllers
/// Контроллер для корридоров бурения на панели
/// </summary>
[ApiController]
[Authorize]
public class DrillFlowChartController : ControllerBase
{
private readonly IDrillFlowChartService drillFlowChartService;
@ -60,17 +62,14 @@ namespace AsbCloudWebApi.Controllers
/// <returns> Список параметров для корридоров бурения </returns>
[HttpGet]
[Route("api/telemetry/{uid}/drillFlowChart")]
[AllowAnonymous]
[ProducesResponseType(typeof(IEnumerable<DrillFlowChartDto>), (int) System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> GetByTelemetryAsync(string uid, DateTime updateFrom = default, CancellationToken token = default)
{
var idCompany = User.GetCompanyId();
var idWell = telemetryService.GetidWellByTelemetryUid(uid);
if (idWell is null)
return BadRequest($"Wrong uid {uid}");
if (idCompany is null || idWell is null || !await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
(int)idWell, token).ConfigureAwait(false))
return Forbid();
var dto = await drillFlowChartService.GetAllAsync((int)idWell,
updateFrom, token);