forked from ddrilling/AsbCloudServer
rename assertion methods
This commit is contained in:
parent
f6bc677a68
commit
2903762f0e
@ -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<IActionResult> 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<IActionResult> 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();
|
||||
|
||||
|
@ -42,7 +42,7 @@ public class ManualDirectoryController : ControllerBase
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
public async Task<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user