Browse Source

Remove `abp.auth.policies`.

Resolve #13950
pull/14023/head
maliming 4 years ago
parent
commit
852dafdb95
No known key found for this signature in database GPG Key ID: 96224957E51C89E
  1. 1
      docs/en/UI/AspNetCore/JavaScript-API/Auth.md
  2. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/ApplicationAuthConfigurationDto.cs
  3. 7
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  4. 4
      npm/packs/core/src/abp.js

1
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.

3
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<string, bool> Policies { get; set; }
public Dictionary<string, bool> GrantedPolicies { get; set; }
public ApplicationAuthConfigurationDto()
{
Policies = new Dictionary<string, bool>();
GrantedPolicies = new Dictionary<string, bool>();
}
}

7
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<string, string>();
var localizer = await StringLocalizerFactory
.CreateByResourceNameOrNullAsync(resourceName);
if (localizer != null)
{
foreach (var localizedString in await localizer.GetAllStringsAsync())

4
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 () {

Loading…
Cancel
Save