From 2903762f0ee0d31f4db0b2c95ee4c2ac07bc7b04 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Thu, 14 Sep 2023 12:01:35 +0500 Subject: [PATCH] rename assertion methods --- AsbCloudWebApi/Controllers/ManualController.cs | 8 ++++---- .../Controllers/ManualDirectoryController.cs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AsbCloudWebApi/Controllers/ManualController.cs b/AsbCloudWebApi/Controllers/ManualController.cs index f68d8d6b..6da171a5 100644 --- a/AsbCloudWebApi/Controllers/ManualController.cs +++ b/AsbCloudWebApi/Controllers/ManualController.cs @@ -46,7 +46,7 @@ public class ManualController : ControllerBase if(!idUser.HasValue) throw new ForbidException("Не удается вас опознать"); - CanUserAccessToManual("Manual.edit"); + AssertUserHasAccessToManual("Manual.edit"); using var fileStream = file.OpenReadStream(); @@ -68,7 +68,7 @@ public class ManualController : ControllerBase [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task GetFileAsync(int id, CancellationToken cancellationToken) { - CanUserAccessToManual("Manual.get"); + AssertUserHasAccessToManual("Manual.get"); var file = await manualCatalogService.GetFileAsync(id, cancellationToken); @@ -90,12 +90,12 @@ public class ManualController : ControllerBase [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task DeleteFileAsync(int id, CancellationToken cancellationToken) { - CanUserAccessToManual("Manual.edit"); + AssertUserHasAccessToManual("Manual.edit"); return Ok(await manualCatalogService.DeleteFileAsync(id, cancellationToken)); } - private void CanUserAccessToManual(string permissionName) + private void AssertUserHasAccessToManual(string permissionName) { var idUser = User.GetUserId(); diff --git a/AsbCloudWebApi/Controllers/ManualDirectoryController.cs b/AsbCloudWebApi/Controllers/ManualDirectoryController.cs index 0e448e01..73c247ac 100644 --- a/AsbCloudWebApi/Controllers/ManualDirectoryController.cs +++ b/AsbCloudWebApi/Controllers/ManualDirectoryController.cs @@ -42,7 +42,7 @@ public class ManualDirectoryController : ControllerBase [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task AddDirectoryAsync(string name, int? idParent, CancellationToken cancellationToken) { - CanUserAccessToManualDirectory("Manual.edit"); + AssertUserHasAccessToManualDirectory("Manual.edit"); return Ok(await manualCatalogService.AddDirectoryAsync(name, idParent, cancellationToken)); } @@ -60,7 +60,7 @@ public class ManualDirectoryController : ControllerBase [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task UpdateDirectoryAsync(int id, string name, CancellationToken cancellationToken) { - CanUserAccessToManualDirectory("Manual.edit"); + AssertUserHasAccessToManualDirectory("Manual.edit"); await manualCatalogService.UpdateDirectoryAsync(id, name, cancellationToken); @@ -79,7 +79,7 @@ public class ManualDirectoryController : ControllerBase [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task DeleteDirectoryAsync(int id, CancellationToken cancellationToken) { - CanUserAccessToManualDirectory("Manual.edit"); + AssertUserHasAccessToManualDirectory("Manual.edit"); return Ok(await manualCatalogService.DeleteDirectoryAsync(id, cancellationToken)); } @@ -95,12 +95,12 @@ public class ManualDirectoryController : ControllerBase [ProducesResponseType(StatusCodes.Status403Forbidden)] public async Task GetAsync(CancellationToken cancellationToken) { - CanUserAccessToManualDirectory("Manual.get"); + AssertUserHasAccessToManualDirectory("Manual.get"); return Ok(await manualDirectoryRepository.GetTreeAsync(cancellationToken)); } - private void CanUserAccessToManualDirectory(string permissionName) + private void AssertUserHasAccessToManualDirectory(string permissionName) { var idUser = User.GetUserId();