|
|
|
@ -16,20 +16,17 @@ namespace Volo.Abp.PermissionManagement
|
|
|
|
|
{
|
|
|
|
|
protected PermissionManagementOptions Options { get; }
|
|
|
|
|
|
|
|
|
|
private readonly IPermissionManager _permissionManager;
|
|
|
|
|
private readonly IPermissionDefinitionManager _permissionDefinitionManager;
|
|
|
|
|
private readonly IStringLocalizerFactory _stringLocalizerFactory;
|
|
|
|
|
protected IPermissionManager PermissionManager { get; }
|
|
|
|
|
protected IPermissionDefinitionManager PermissionDefinitionManager { get; }
|
|
|
|
|
|
|
|
|
|
public PermissionAppService(
|
|
|
|
|
IPermissionManager permissionManager,
|
|
|
|
|
IPermissionDefinitionManager permissionDefinitionManager,
|
|
|
|
|
IStringLocalizerFactory stringLocalizerFactory,
|
|
|
|
|
IOptions<PermissionManagementOptions> options)
|
|
|
|
|
{
|
|
|
|
|
Options = options.Value;
|
|
|
|
|
_permissionManager = permissionManager;
|
|
|
|
|
_permissionDefinitionManager = permissionDefinitionManager;
|
|
|
|
|
_stringLocalizerFactory = stringLocalizerFactory;
|
|
|
|
|
PermissionManager = permissionManager;
|
|
|
|
|
PermissionDefinitionManager = permissionDefinitionManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual async Task<GetPermissionListResultDto> GetAsync(string providerName, string providerKey)
|
|
|
|
@ -44,12 +41,12 @@ namespace Volo.Abp.PermissionManagement
|
|
|
|
|
|
|
|
|
|
var multiTenancySide = CurrentTenant.GetMultiTenancySide();
|
|
|
|
|
|
|
|
|
|
foreach (var group in _permissionDefinitionManager.GetGroups())
|
|
|
|
|
foreach (var group in PermissionDefinitionManager.GetGroups())
|
|
|
|
|
{
|
|
|
|
|
var groupDto = new PermissionGroupDto
|
|
|
|
|
{
|
|
|
|
|
Name = group.Name,
|
|
|
|
|
DisplayName = group.DisplayName.Localize(_stringLocalizerFactory),
|
|
|
|
|
DisplayName = group.DisplayName.Localize(StringLocalizerFactory),
|
|
|
|
|
Permissions = new List<PermissionGrantInfoDto>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -68,13 +65,13 @@ namespace Volo.Abp.PermissionManagement
|
|
|
|
|
var grantInfoDto = new PermissionGrantInfoDto
|
|
|
|
|
{
|
|
|
|
|
Name = permission.Name,
|
|
|
|
|
DisplayName = permission.DisplayName.Localize(_stringLocalizerFactory),
|
|
|
|
|
DisplayName = permission.DisplayName.Localize(StringLocalizerFactory),
|
|
|
|
|
ParentName = permission.Parent?.Name,
|
|
|
|
|
AllowedProviders = permission.Providers,
|
|
|
|
|
GrantedProviders = new List<ProviderInfoDto>()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var grantInfo = await _permissionManager.GetAsync(permission.Name, providerName, providerKey);
|
|
|
|
|
var grantInfo = await PermissionManager.GetAsync(permission.Name, providerName, providerKey);
|
|
|
|
|
|
|
|
|
|
grantInfoDto.IsGranted = grantInfo.IsGranted;
|
|
|
|
|
|
|
|
|
@ -105,7 +102,7 @@ namespace Volo.Abp.PermissionManagement
|
|
|
|
|
|
|
|
|
|
foreach (var permissionDto in input.Permissions)
|
|
|
|
|
{
|
|
|
|
|
await _permissionManager.SetAsync(permissionDto.Name, providerName, providerKey, permissionDto.IsGranted);
|
|
|
|
|
await PermissionManager.SetAsync(permissionDto.Name, providerName, providerKey, permissionDto.IsGranted);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|