From a86bc20d22af51c10abf6f1fee0151f37a738a51 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sat, 1 Jan 2022 20:50:37 +0330 Subject: [PATCH] #269 removing some unused code --- .../Controllers/RChargableFeatureType.cs | 26 ------ .../UserScopeCheckEnabledControllerBase.cs | 92 ------------------- RSecurityBackend/RSecurityBackend.xml | 65 ------------- 3 files changed, 183 deletions(-) delete mode 100644 RSecurityBackend/Controllers/RChargableFeatureType.cs delete mode 100644 RSecurityBackend/Controllers/UserScopeCheckEnabledControllerBase.cs diff --git a/RSecurityBackend/Controllers/RChargableFeatureType.cs b/RSecurityBackend/Controllers/RChargableFeatureType.cs deleted file mode 100644 index f35019b3..00000000 --- a/RSecurityBackend/Controllers/RChargableFeatureType.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace RBilling.Models.Tenant.Db -{ - /// - /// Chargable Feature For Tenant Type - /// - public enum RChargableFeatureType - { - /// - /// yes/no - /// - Boolean = 0, - /// - /// 0, ... - /// - RegularNumber = 1, - /// - /// 1.222 or large numbers - /// - FloatNumber - } -} diff --git a/RSecurityBackend/Controllers/UserScopeCheckEnabledControllerBase.cs b/RSecurityBackend/Controllers/UserScopeCheckEnabledControllerBase.cs deleted file mode 100644 index ad51749e..00000000 --- a/RSecurityBackend/Controllers/UserScopeCheckEnabledControllerBase.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using RSecurityBackend.Models.Generic; -using RSecurityBackend.Services; - - -namespace RSecurityBackend.Controllers -{ - /// - /// base class for controllers needing UserScopeCheck - /// - public abstract class UserScopeCheckEnabledControllerBase : Controller - { - /// - /// UserScopeCheck method EntityShortName; - /// - /// - /// RBillingSecurableItem.TenantEntityShortName - /// - protected abstract string UserScopeCheckEntityShortName { get; } - - /// - /// UserScopeCheck method OperationShortName - /// - /// - /// SecurableItem.ViewOperationShortName - /// - protected abstract string UserScopeCheckOperationShortName { get; } - - - /// - /// returns user id if user is a guest, and empty if he/she has access to view all users information - /// - /// - protected async Task> GetUserIdUnlessUserHavePermissionToReadAllUsersDataWhichReturnEmptyUserId() - { - Guid userId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); - - RServiceResult canReadAllUsersData = - await _userPermissionChecker.Check - ( - userId, - new Guid(User.Claims.FirstOrDefault(c => c.Type == "SessionId").Value), - UserScopeCheckEntityShortName, - UserScopeCheckOperationShortName - - ); - - if (!string.IsNullOrEmpty(canReadAllUsersData.ExceptionString)) - return new RServiceResult(userId, canReadAllUsersData.ExceptionString); - if (canReadAllUsersData.Result) - { - userId = Guid.Empty; - } - return new RServiceResult(userId); - } - - /// - /// can current user read this userId daya - /// - /// - /// - protected async Task> CanReadUserData(Guid userId) - { - RServiceResult scopeForUserId = await GetUserIdUnlessUserHavePermissionToReadAllUsersDataWhichReturnEmptyUserId(); - if(!string.IsNullOrEmpty(scopeForUserId.ExceptionString)) - { - return new RServiceResult(false, scopeForUserId.ExceptionString); - } - return new RServiceResult(scopeForUserId.Result == Guid.Empty || scopeForUserId.Result == userId); - } - - /// - /// Permission Checker Service - /// - protected readonly IUserPermissionChecker _userPermissionChecker; - - - /// - /// constructor - /// - /// - public UserScopeCheckEnabledControllerBase(IUserPermissionChecker userPermissionChecker) - { - _userPermissionChecker = userPermissionChecker; - } - - - } -} diff --git a/RSecurityBackend/RSecurityBackend.xml b/RSecurityBackend/RSecurityBackend.xml index 41aa965b..77c2f5e9 100644 --- a/RSecurityBackend/RSecurityBackend.xml +++ b/RSecurityBackend/RSecurityBackend.xml @@ -625,51 +625,6 @@ - - - base class for controllers needing UserScopeCheck - - - - - UserScopeCheck method EntityShortName; - - - RBillingSecurableItem.TenantEntityShortName - - - - - UserScopeCheck method OperationShortName - - - SecurableItem.ViewOperationShortName - - - - - returns user id if user is a guest, and empty if he/she has access to view all users information - - - - - - can current user read this userId daya - - - - - - - Permission Checker Service - - - - - constructor - - - Security EF DbContext @@ -3953,25 +3908,5 @@ - - - Chargable Feature For Tenant Type - - - - - yes/no - - - - - 0, ... - - - - - 1.222 or large numbers - -