From 852dafdb957f5c152f84d1f2c5aa33290952134f Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 15 Sep 2022 14:13:49 +0800 Subject: [PATCH] Remove `abp.auth.policies`. Resolve #13950 --- docs/en/UI/AspNetCore/JavaScript-API/Auth.md | 1 - .../ApplicationAuthConfigurationDto.cs | 3 --- .../AbpApplicationConfigurationAppService.cs | 7 ++----- npm/packs/core/src/abp.js | 4 +--- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/en/UI/AspNetCore/JavaScript-API/Auth.md b/docs/en/UI/AspNetCore/JavaScript-API/Auth.md index 45af8c4b3e..b50e077ba6 100644 --- a/docs/en/UI/AspNetCore/JavaScript-API/Auth.md +++ b/docs/en/UI/AspNetCore/JavaScript-API/Auth.md @@ -20,5 +20,4 @@ if (abp.auth.isGranted('DeleteUsers')) { * ` abp.auth.isAnyGranted(...)`: Gets one or more permission/policy names and returns `true` if at least one of them has granted. * `abp.auth.areAllGranted(...)`: Gets one or more permission/policy names and returns `true` if all of them of them have granted. -* `abp.auth.policies`: This is an object where its keys are the permission/policy names. You can find all permission/policy names here. * `abp.auth.grantedPolicies`: This is an object where its keys are the permission/policy names. You can find the granted permission/policy names here. \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs index be5a022b01..3b94ea0b72 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs @@ -6,13 +6,10 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations; [Serializable] public class ApplicationAuthConfigurationDto { - public Dictionary Policies { get; set; } - public Dictionary GrantedPolicies { get; set; } public ApplicationAuthConfigurationDto() { - Policies = new Dictionary(); GrantedPolicies = new Dictionary(); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs index 0deae4b5b3..4254b5479f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs @@ -185,8 +185,6 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp foreach (var policyName in otherPolicyNames) { - authConfig.Policies[policyName] = true; - if (await _authorizationService.IsGrantedAsync(policyName)) { authConfig.GrantedPolicies[policyName] = true; @@ -196,7 +194,6 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp var result = await _permissionChecker.IsGrantedAsync(abpPolicyNames.ToArray()); foreach (var (key, value) in result.Result) { - authConfig.Policies[key] = true; if (value == PermissionGrantResult.Granted) { authConfig.GrantedPolicies[key] = true; @@ -228,10 +225,10 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp foreach (var resourceName in resourceNames) { var dictionary = new Dictionary(); - + var localizer = await StringLocalizerFactory .CreateByResourceNameOrNullAsync(resourceName); - + if (localizer != null) { foreach (var localizedString in await localizer.GetAllStringsAsync()) diff --git a/npm/packs/core/src/abp.js b/npm/packs/core/src/abp.js index 074d4f0f50..b4c31c18a5 100644 --- a/npm/packs/core/src/abp.js +++ b/npm/packs/core/src/abp.js @@ -201,12 +201,10 @@ var abp = abp || {}; abp.auth = abp.auth || {}; - abp.auth.policies = abp.auth.policies || {}; - abp.auth.grantedPolicies = abp.auth.grantedPolicies || {}; abp.auth.isGranted = function (policyName) { - return abp.auth.policies[policyName] != undefined && abp.auth.grantedPolicies[policyName] != undefined; + return abp.auth.grantedPolicies[policyName] != undefined; }; abp.auth.isAnyGranted = function () {