From 9876edcb9f05565c04169868ccfcb030933266cf Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 15 Jun 2022 16:01:50 +0500 Subject: [PATCH] Fix AdminUserRoleController.*Forbid predicates. --- AsbCloudWebApi/Controllers/AdminUserRoleController.cs | 10 ++-------- AsbCloudWebApi/Controllers/CrudController.cs | 1 + 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/AsbCloudWebApi/Controllers/AdminUserRoleController.cs b/AsbCloudWebApi/Controllers/AdminUserRoleController.cs index b9a7b8cd..2de464f9 100644 --- a/AsbCloudWebApi/Controllers/AdminUserRoleController.cs +++ b/AsbCloudWebApi/Controllers/AdminUserRoleController.cs @@ -14,21 +14,15 @@ namespace AsbCloudWebApi.Controllers public AdminUserRoleController(IUserRoleService service) : base(service) { - InsertForbidAsync = (role, token) => - { - return Task.FromResult(role?.IdType == 1); - }; - UpdateForbidAsync = async (dto, token) => { var role = await service.GetAsync(dto.Id, token); return role?.IdType == 1; }; - DeleteForbidAsync = async (id, token) => + DeleteForbidAsync = (id, token) => { - var role = await service.GetAsync(id, token); - return role?.IdType == 1; + return Task.FromResult(id == 1); }; } } diff --git a/AsbCloudWebApi/Controllers/CrudController.cs b/AsbCloudWebApi/Controllers/CrudController.cs index 06c1e811..8c6df061 100644 --- a/AsbCloudWebApi/Controllers/CrudController.cs +++ b/AsbCloudWebApi/Controllers/CrudController.cs @@ -127,6 +127,7 @@ namespace AsbCloudWebApi.Controllers /// /// 1 - успешно удалено, 0 - нет [HttpDelete("{id}")] + [Permission] public virtual async Task> DeleteAsync(int id, CancellationToken token) { if (DeleteForbidAsync is not null && await DeleteForbidAsync(id, token))