Browse Source

Merge pull request #8914 from abpframework/maliming-patch-RequirePermissionsSimpleBatchStateChecker

Prevent adding duplicate models.
pull/8916/head
liangshiwei 5 years ago
committed by GitHub
parent
commit
f62945fb18
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RequirePermissionsSimpleBatchStateChecker.cs

13
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;
}

Loading…
Cancel
Save