From 3fcf1c5bb3863dbeb4374c2a3a240e83c63a8200 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 14 May 2021 23:23:20 +0800 Subject: [PATCH] Add ClearCheckModels method to RequirePermissionsSimpleBatchStateChecker Resolve #9028 --- .../Toolbars/ToolbarManager.cs | 2 ++ .../RequirePermissionsSimpleBatchStateChecker.cs | 14 ++++++-------- .../Volo/Abp/Ui/Navigation/MenuManager.cs | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs index d27ab355c0..ecd73ac5ab 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs @@ -36,6 +36,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars using (var scope = ServiceProvider.CreateScope()) { + RequirePermissionsSimpleBatchStateChecker.Instance.ClearCheckModels(); + var context = new ToolbarConfigurationContext(ThemeManager.CurrentTheme, toolbar, scope.ServiceProvider); foreach (var contributor in Options.Contributors) diff --git a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs index 7c763bcfab..ebd91bf14f 100644 --- a/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs +++ b/framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs @@ -22,17 +22,15 @@ namespace Volo.Abp.Authorization.Permissions { Check.NotNullOrEmpty(models, nameof(models)); - foreach (var model in models) - { - _models.RemoveAll(x => x.State.GetType() == model.State.GetType() && - x.RequiresAll == model.RequiresAll && - x.Permissions.SequenceEqual(model.Permissions)); - _models.Add(model); - } - + _models.AddRange(models); return this; } + public void ClearCheckModels() + { + _models.Clear(); + } + public override async Task> IsEnabledAsync(SimpleBatchStateCheckerContext context) { var permissionChecker = context.ServiceProvider.GetRequiredService(); diff --git a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs index fe5c5da242..d58c88b6e6 100644 --- a/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs +++ b/framework/src/Volo.Abp.UI.Navigation/Volo/Abp/Ui/Navigation/MenuManager.cs @@ -31,6 +31,8 @@ namespace Volo.Abp.UI.Navigation using (var scope = ServiceScopeFactory.CreateScope()) { + RequirePermissionsSimpleBatchStateChecker.Instance.ClearCheckModels(); + var context = new MenuConfigurationContext(menu, scope.ServiceProvider); foreach (var contributor in Options.MenuContributors)