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