Merge pull request #9978 from abpframework/liangshiwei/identity

Improve PermissionDataSeeder
pull/9984/head^2
maliming 4 years ago committed by GitHub
commit 083fabacf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,8 @@
using System;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Volo.Abp.PermissionManagement.MongoDB;
using Volo.Abp.Uow;
namespace Volo.Abp.Identity.MongoDB
{
@ -24,6 +24,11 @@ namespace Volo.Abp.Identity.MongoDB
{
options.ConnectionStrings.Default = connectionString;
});
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
@ -32,13 +33,11 @@ namespace Volo.Abp.PermissionManagement
{
using (CurrentTenant.Change(tenantId))
{
foreach (var permissionName in grantedPermissions)
{
if (await PermissionGrantRepository.FindAsync(permissionName, providerName, providerKey) != null)
{
continue;
}
var names = grantedPermissions.ToArray();
var existsPermissionGrants = (await PermissionGrantRepository.GetListAsync(names, providerName, providerKey)).Select(x => x.Name).ToList();
foreach (var permissionName in names.Except(existsPermissionGrants))
{
await PermissionGrantRepository.InsertAsync(
new PermissionGrant(
GuidGenerator.Create(),

Loading…
Cancel
Save