Browse Source
Merge pull request #9978 from abpframework/liangshiwei/identity
Improve PermissionDataSeeder
pull/9994/head
maliming
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
11 additions and
7 deletions
-
modules/identity/test/Volo.Abp.Identity.MongoDB.Tests/Volo/Abp/Identity/MongoDB/AbpIdentityMongoDbTestModule.cs
-
modules/permission-management/src/Volo.Abp.PermissionManagement.Domain/Volo/Abp/PermissionManagement/PermissionDataSeeder.cs
|
|
|
@ -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(), |
|
|
|
|