mirror of https://github.com/abpframework/abp.git
8 changed files with 61 additions and 47 deletions
@ -1,33 +1,22 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.Guids; |
|||
using Volo.Abp.Permissions; |
|||
|
|||
namespace Volo.Abp.Identity |
|||
{ |
|||
public class UserPermissionManagementProvider : PermissionManagementProvider |
|||
{ |
|||
public override string Name => "User"; |
|||
public const string ProviderName = "User"; //TODO: Share a common string with UserPermissionValueProvider (same is true for the role)
|
|||
|
|||
public override string Name => ProviderName; |
|||
|
|||
public UserPermissionManagementProvider(IPermissionGrantRepository |
|||
permissionGrantRepository, |
|||
IGuidGenerator guidGenerator) |
|||
: base( |
|||
permissionGrantRepository, |
|||
permissionGrantRepository, |
|||
guidGenerator) |
|||
{ |
|||
} |
|||
|
|||
public override async Task<PermissionValueProviderGrantInfo> CheckAsync(string name, string providerName, string providerKey) |
|||
{ |
|||
if (providerName != Name) |
|||
{ |
|||
return PermissionValueProviderGrantInfo.NonGranted; |
|||
} |
|||
|
|||
return new PermissionValueProviderGrantInfo( |
|||
await PermissionGrantRepository.FindAsync(name, providerName, providerKey) != null, |
|||
providerKey |
|||
); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace Volo.Abp.Permissions |
|||
{ |
|||
public static class RolePermissionManagerExtensions |
|||
{ |
|||
public static Task<List<PermissionWithGrantedProviders>> GetAllForRoleAsync([NotNull] this IPermissionManager permissionManager, string roleName) |
|||
{ |
|||
Check.NotNull(permissionManager, nameof(permissionManager)); |
|||
|
|||
return permissionManager.GetAllAsync(RolePermissionManagementProvider.ProviderName, roleName); |
|||
} |
|||
|
|||
public static Task SetForUserAsync([NotNull] this IPermissionManager permissionManager, Guid userId, [NotNull] string name, bool isGranted) |
|||
{ |
|||
Check.NotNull(permissionManager, nameof(permissionManager)); |
|||
|
|||
return permissionManager.SetAsync(name, UserPermissionManagementProvider.ProviderName, userId.ToString(), isGranted); |
|||
} |
|||
} |
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
namespace Volo.Abp.Permissions |
|||
{ |
|||
public static class PermissionManagerSyncExtensions |
|||
{ |
|||
//TODO: Add sync extension methods for all permission manager methods.
|
|||
//TODO: Also add sync extension methods for all value provider extensions.
|
|||
} |
|||
} |
|||
Loading…
Reference in new issue