From c49e3fb92681f7a759d7ab03f04c29238d603be5 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 7 May 2021 12:08:12 +0800 Subject: [PATCH] Prevent adding duplicate models. --- .../RequirePermissionsSimpleBatchStateChecker.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 5cce51ec51..f02ce38c74 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 @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; @@ -22,7 +22,16 @@ namespace Volo.Abp.Authorization.Permissions { Check.NotNullOrEmpty(models, nameof(models)); - _models.AddRange(models); + foreach (var model in models) + { + if (!_models.Any(x => x.State.GetType() == model.State.GetType() && + x.RequiresAll == model.RequiresAll && + x.Permissions.SequenceEqual(model.Permissions))) + { + _models.Add(model); + } + } + return this; }