Fixed permission manager.

pull/208/head
Halil İbrahim Kalkan 7 years ago
parent 2ee0dbec8a
commit ed28669f6d

@ -7,7 +7,7 @@ namespace Volo.Abp.Permissions
{
string Name { get; }
Task<bool?> IsGrantedAsync([NotNull] PermissionDefinition permission, [CanBeNull] string providerKey);
Task<bool?> IsGrantedAsync([NotNull] PermissionDefinition permission, [CanBeNull] string providerName, [CanBeNull] string providerKey);
Task SetAsync([NotNull] PermissionDefinition permission, bool isGranted, [CanBeNull] string providerKey);

@ -50,7 +50,7 @@ namespace Volo.Abp.Permissions
Check.NotNull(name, nameof(name));
Check.NotNull(providerName, nameof(providerName));
return IsGrantedInternalAsync(name, providerName, providerKey, fallback);
return IsGrantedInternalAsync(name, providerName, providerKey);
}
public virtual async Task<bool> IsGrantedInternalAsync(string name, string providerName, string providerKey, bool fallback = true)
@ -71,7 +71,7 @@ namespace Volo.Abp.Permissions
foreach (var provider in providers)
{
var value = await provider.IsGrantedAsync(permission, providerKey);
var value = await provider.IsGrantedAsync(permission, providerName, providerKey);
if (value != null)
{
return value.Value;
@ -150,7 +150,9 @@ namespace Volo.Abp.Permissions
}
}
protected virtual async Task<List<PermissionGrantInfo>> GetAllFromProvidersAsync([NotNull] List<IPermissionValueProvider> providers, [CanBeNull] string providerKey)
protected virtual async Task<List<PermissionGrantInfo>> GetAllFromProvidersAsync(
[NotNull] List<IPermissionValueProvider> providers,
[CanBeNull] string providerKey)
{
var permissionDefinitions = PermissionDefinitionManager.GetAll();
var permissionGrantInfos = new Dictionary<string, PermissionGrantInfo>();
@ -161,7 +163,7 @@ namespace Volo.Abp.Permissions
foreach (var provider in providers)
{
var value = await provider.IsGrantedAsync(permission, providerKey);
var value = await provider.IsGrantedAsync(permission, provider.Name, providerKey);
if (value != null)
{
permissionGrantInfos[permission.Name] =

@ -14,7 +14,7 @@ namespace Volo.Abp.Permissions
PermissionStore = permissionStore;
}
public abstract Task<bool?> IsGrantedAsync(PermissionDefinition permission, string providerKey);
public abstract Task<bool?> IsGrantedAsync(PermissionDefinition permission, string providerName, string providerKey);
public abstract Task SetAsync(PermissionDefinition permission, bool isGranted, string providerKey);

@ -0,0 +1,47 @@
using System.Threading.Tasks;
using Volo.Abp.Permissions;
namespace Volo.Abp.Session
{
//TODO: This should be located under Identity, or we should create a Volo.Abp.Roles package (with role store implementation)...!
//public class RolePermissionValueProvider : PermissionValueProvider
//{
// public const string ProviderName = "Role";
// public override string Name => ProviderName;
// protected ICurrentUser CurrentUser { get; }
// public RolePermissionValueProvider(IPermissionStore permissionStore, ICurrentUser currentUser)
// : base(permissionStore)
// {
// CurrentUser = currentUser;
// }
// public override async Task<bool?> IsGrantedAsync(PermissionDefinition permission, string providerKey)
// {
// if (providerKey == null)
// {
// if (CurrentUser.Id == null)
// {
// return null;
// }
// providerKey = CurrentUser.Id.ToString();
// }
// return await PermissionStore.IsGrantedAsync(permission.Name, Name, providerKey);
// }
// public override Task SetAsync(PermissionDefinition permission, bool isGranted, string providerKey)
// {
// return PermissionStore.SetAsync(permission.Name, isGranted, Name, providerKey);
// }
// public override Task ClearAsync(PermissionDefinition permission, string providerKey)
// {
// return PermissionStore.DeleteAsync(permission.Name, Name, providerKey);
// }
//}
}

@ -17,7 +17,7 @@ namespace Volo.Abp.Session
CurrentUser = currentUser;
}
public override async Task<bool?> IsGrantedAsync(PermissionDefinition permission, string providerKey)
public override async Task<bool?> IsGrantedAsync(PermissionDefinition permission, string providerName, string providerKey)
{
if (providerKey == null)
{

Loading…
Cancel
Save