mirror of https://github.com/abpframework/abp.git
6 changed files with 76 additions and 54 deletions
@ -0,0 +1,16 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp.Identity |
||||
|
{ |
||||
|
[Serializable] |
||||
|
public class IdentityRoleNameChangedEto |
||||
|
{ |
||||
|
public Guid Id { get; set; } |
||||
|
|
||||
|
public Guid? TenantId { get; set; } |
||||
|
|
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public string OldName { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,26 +1,26 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Authorization.Permissions; |
using Volo.Abp.Authorization.Permissions; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.Domain.Entities.Events; |
using Volo.Abp.Domain.Entities.Events.Distributed; |
||||
using Volo.Abp.EventBus; |
using Volo.Abp.EventBus; |
||||
using Volo.Abp.Identity; |
using Volo.Abp.Identity; |
||||
|
|
||||
namespace Volo.Abp.PermissionManagement.Identity |
namespace Volo.Abp.PermissionManagement.Identity |
||||
{ |
{ |
||||
// public class RoleDeletedEventHandler :
|
public class RoleDeletedEventHandler : |
||||
// ILocalEventHandler<EntityDeletedEventData<IdentityRole>>,
|
ILocalEventHandler<EntityDeletedEto<IdentityRoleEto>>, |
||||
// ITransientDependency
|
ITransientDependency |
||||
// {
|
{ |
||||
// protected IPermissionManager PermissionManager { get; }
|
protected IPermissionManager PermissionManager { get; } |
||||
//
|
|
||||
// public RoleDeletedEventHandler(IPermissionManager permissionManager)
|
public RoleDeletedEventHandler(IPermissionManager permissionManager) |
||||
// {
|
{ |
||||
// PermissionManager = permissionManager;
|
PermissionManager = permissionManager; |
||||
// }
|
} |
||||
//
|
|
||||
// public virtual async Task HandleEventAsync(EntityDeletedEventData<IdentityRole> eventData)
|
public async Task HandleEventAsync(EntityDeletedEto<IdentityRoleEto> eventData) |
||||
// {
|
{ |
||||
// await PermissionManager.DeleteAsync(RolePermissionValueProvider.ProviderName, eventData.Entity.Name);
|
await PermissionManager.DeleteAsync(RolePermissionValueProvider.ProviderName, eventData.Entity.Name); |
||||
// }
|
} |
||||
// }
|
} |
||||
} |
} |
||||
|
|||||
@ -1,45 +1,33 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using Volo.Abp.Authorization.Permissions; |
using Volo.Abp.Authorization.Permissions; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.Domain.Entities.Events; |
using Volo.Abp.EventBus.Distributed; |
||||
using Volo.Abp.EventBus; |
|
||||
using Volo.Abp.Identity; |
using Volo.Abp.Identity; |
||||
|
|
||||
namespace Volo.Abp.PermissionManagement.Identity |
namespace Volo.Abp.PermissionManagement.Identity |
||||
{ |
{ |
||||
//TODO: This code can not be here!
|
public class RoleUpdateEventHandler : |
||||
|
IDistributedEventHandler<IdentityRoleNameChangedEto>, |
||||
|
ITransientDependency |
||||
|
{ |
||||
|
protected IPermissionManager PermissionManager { get; } |
||||
|
protected IPermissionGrantRepository PermissionGrantRepository { get; } |
||||
|
|
||||
|
public RoleUpdateEventHandler( |
||||
|
IPermissionManager permissionManager, |
||||
|
IPermissionGrantRepository permissionGrantRepository) |
||||
|
{ |
||||
|
PermissionManager = permissionManager; |
||||
|
PermissionGrantRepository = permissionGrantRepository; |
||||
|
} |
||||
|
|
||||
// public class RoleUpdateEventHandler :
|
public async Task HandleEventAsync(IdentityRoleNameChangedEto eventData) |
||||
// ILocalEventHandler<IdentityRoleNameChangedEvent>,
|
{ |
||||
// ITransientDependency
|
var permissionGrantsInRole = await PermissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, eventData.OldName); |
||||
// {
|
foreach (var permissionGrant in permissionGrantsInRole) |
||||
// protected IIdentityRoleRepository RoleRepository { get; }
|
{ |
||||
// protected IPermissionManager PermissionManager { get; }
|
await PermissionManager.UpdateProviderKeyAsync(permissionGrant, eventData.Name); |
||||
// protected IPermissionGrantRepository PermissionGrantRepository { get; }
|
} |
||||
//
|
} |
||||
// public RoleUpdateEventHandler(
|
} |
||||
// IIdentityRoleRepository roleRepository,
|
|
||||
// IPermissionManager permissionManager,
|
|
||||
// IPermissionGrantRepository permissionGrantRepository)
|
|
||||
// {
|
|
||||
// RoleRepository = roleRepository;
|
|
||||
// PermissionManager = permissionManager;
|
|
||||
// PermissionGrantRepository = permissionGrantRepository;
|
|
||||
// }
|
|
||||
//
|
|
||||
// public virtual async Task HandleEventAsync(IdentityRoleNameChangedEvent eventData)
|
|
||||
// {
|
|
||||
// var role = await RoleRepository.FindAsync(eventData.IdentityRole.Id, false);
|
|
||||
// if (role == null)
|
|
||||
// {
|
|
||||
// return;
|
|
||||
// }
|
|
||||
//
|
|
||||
// var permissionGrantsInRole = await PermissionGrantRepository.GetListAsync(RolePermissionValueProvider.ProviderName, eventData.OldName);
|
|
||||
// foreach (var permissionGrant in permissionGrantsInRole)
|
|
||||
// {
|
|
||||
// await PermissionManager.UpdateProviderKeyAsync(permissionGrant, eventData.IdentityRole.Name);
|
|
||||
// }
|
|
||||
// }
|
|
||||
// }
|
|
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue