|
|
|
@ -1,11 +1,14 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
using Microsoft.Extensions.Localization; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using Volo.Abp.Identity.Localization; |
|
|
|
using Volo.Abp.Threading; |
|
|
|
|
|
|
|
namespace Volo.Abp.Identity |
|
|
|
@ -14,6 +17,7 @@ namespace Volo.Abp.Identity |
|
|
|
{ |
|
|
|
protected override CancellationToken CancellationToken => _cancellationTokenProvider.Token; |
|
|
|
|
|
|
|
private readonly IStringLocalizer<IdentityResource> _localizer; |
|
|
|
private readonly ICancellationTokenProvider _cancellationTokenProvider; |
|
|
|
|
|
|
|
public IdentityRoleManager( |
|
|
|
@ -21,7 +25,8 @@ namespace Volo.Abp.Identity |
|
|
|
IEnumerable<IRoleValidator<IdentityRole>> roleValidators, |
|
|
|
ILookupNormalizer keyNormalizer, |
|
|
|
IdentityErrorDescriber errors, |
|
|
|
ILogger<IdentityRoleManager> logger, |
|
|
|
ILogger<IdentityRoleManager> logger, |
|
|
|
IStringLocalizer<IdentityResource> localizer, |
|
|
|
ICancellationTokenProvider cancellationTokenProvider) |
|
|
|
: base( |
|
|
|
store, |
|
|
|
@ -30,6 +35,7 @@ namespace Volo.Abp.Identity |
|
|
|
errors, |
|
|
|
logger) |
|
|
|
{ |
|
|
|
_localizer = localizer; |
|
|
|
_cancellationTokenProvider = cancellationTokenProvider; |
|
|
|
} |
|
|
|
|
|
|
|
@ -43,5 +49,25 @@ namespace Volo.Abp.Identity |
|
|
|
|
|
|
|
return role; |
|
|
|
} |
|
|
|
|
|
|
|
public override async Task<IdentityResult> SetRoleNameAsync(IdentityRole role, string name) |
|
|
|
{ |
|
|
|
if (role.IsStatic && role.Name != name) |
|
|
|
{ |
|
|
|
throw new BusinessException(_localizer["Identity.StaticRoleRenamingErrorMessage"]); // TODO: localize & change exception type
|
|
|
|
} |
|
|
|
|
|
|
|
return await base.SetRoleNameAsync(role,name); |
|
|
|
} |
|
|
|
|
|
|
|
public override async Task<IdentityResult> DeleteAsync(IdentityRole role) |
|
|
|
{ |
|
|
|
if (role.IsStatic) |
|
|
|
{ |
|
|
|
throw new BusinessException(_localizer["Identity.StaticRoleDeletionErrorMessage"]); // TODO: localize & change exception type
|
|
|
|
} |
|
|
|
|
|
|
|
return await base.DeleteAsync(role); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|