Browse Source

Merge pull request #3178 from abpframework/Cotur-Virtualization-Identity

Make Identity module services easily overridable by inheritance
pull/3181/head
Halil İbrahim Kalkan 6 years ago
committed by GitHub
parent
commit
ace4b5526e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
  2. 54
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs
  3. 20
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs
  4. 30
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs
  5. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityResultException.cs
  6. 12
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimTypeManager.cs
  7. 8
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeedContributor.cs
  8. 40
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs
  9. 14
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs
  10. 48
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs
  11. 2
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserLogin.cs
  12. 6
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs
  13. 32
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs
  14. 84
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs
  15. 6
      modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserRoleFinder.cs
  16. 4
      modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs
  17. 12
      modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientIdentityUserLookupService.cs
  18. 4
      modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientUserRoleFinder.cs
  19. 16
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs
  20. 22
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs
  21. 4
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserLookupController.cs
  22. 16
      modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs
  23. 4
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs
  24. 5
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs
  25. 23
      modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs
  26. 4
      modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs
  27. 2
      modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs
  28. 6
      modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RolePermissionManagementProvider.cs
  29. 2
      modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RoleUpdateEventHandler.cs

28
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs

@ -10,34 +10,34 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Roles.Default)]
public class IdentityRoleAppService : IdentityAppServiceBase, IIdentityRoleAppService
{
private readonly IdentityRoleManager _roleManager;
private readonly IIdentityRoleRepository _roleRepository;
protected IdentityRoleManager RoleManager { get; }
protected IIdentityRoleRepository RoleRepository { get; }
public IdentityRoleAppService(
IdentityRoleManager roleManager,
IIdentityRoleRepository roleRepository)
{
_roleManager = roleManager;
_roleRepository = roleRepository;
RoleManager = roleManager;
RoleRepository = roleRepository;
}
public virtual async Task<IdentityRoleDto> GetAsync(Guid id)
{
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(
await _roleManager.GetByIdAsync(id));
await RoleManager.GetByIdAsync(id));
}
public virtual async Task<ListResultDto<IdentityRoleDto>> GetAllListAsync()
{
var list = await _roleRepository.GetListAsync();
var list = await RoleRepository.GetListAsync();
return new ListResultDto<IdentityRoleDto>(
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list));
}
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await _roleRepository.GetCountAsync();
var list = await RoleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await RoleRepository.GetCountAsync();
return new PagedResultDto<IdentityRoleDto>(
totalCount,
@ -53,7 +53,7 @@ namespace Volo.Abp.Identity
role.IsDefault = input.IsDefault;
role.IsPublic = input.IsPublic;
(await _roleManager.CreateAsync(role)).CheckErrors();
(await RoleManager.CreateAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
@ -62,15 +62,15 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Roles.Update)]
public virtual async Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
{
var role = await _roleManager.GetByIdAsync(id);
var role = await RoleManager.GetByIdAsync(id);
role.ConcurrencyStamp = input.ConcurrencyStamp;
(await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors();
(await RoleManager.SetRoleNameAsync(role, input.Name)).CheckErrors();
role.IsDefault = input.IsDefault;
role.IsPublic = input.IsPublic;
(await _roleManager.UpdateAsync(role)).CheckErrors();
(await RoleManager.UpdateAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
@ -79,13 +79,13 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Roles.Delete)]
public virtual async Task DeleteAsync(Guid id)
{
var role = await _roleManager.FindByIdAsync(id.ToString());
var role = await RoleManager.FindByIdAsync(id.ToString());
if (role == null)
{
return;
}
(await _roleManager.DeleteAsync(role)).CheckErrors();
(await RoleManager.DeleteAsync(role)).CheckErrors();
}
}
}

54
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserAppService.cs

@ -9,15 +9,15 @@ namespace Volo.Abp.Identity
{
public class IdentityUserAppService : IdentityAppServiceBase, IIdentityUserAppService
{
private readonly IdentityUserManager _userManager;
private readonly IIdentityUserRepository _userRepository;
protected IdentityUserManager UserManager { get; }
protected IIdentityUserRepository UserRepository { get; }
public IdentityUserAppService(
IdentityUserManager userManager,
IIdentityUserRepository userRepository)
{
_userManager = userManager;
_userRepository = userRepository;
UserManager = userManager;
UserRepository = userRepository;
}
//TODO: [Authorize(IdentityPermissions.Users.Default)] should go the IdentityUserAppService class.
@ -25,15 +25,15 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityUserDto> GetAsync(Guid id)
{
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(
await _userManager.GetByIdAsync(id)
await UserManager.GetByIdAsync(id)
);
}
[Authorize(IdentityPermissions.Users.Default)]
public virtual async Task<PagedResultDto<IdentityUserDto>> GetListAsync(GetIdentityUsersInput input)
{
var count = await _userRepository.GetCountAsync(input.Filter);
var list = await _userRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter);
var count = await UserRepository.GetCountAsync(input.Filter);
var list = await UserRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter);
return new PagedResultDto<IdentityUserDto>(
count,
@ -44,7 +44,7 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Users.Default)]
public virtual async Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
{
var roles = await _userRepository.GetRolesAsync(id);
var roles = await UserRepository.GetRolesAsync(id);
return new ListResultDto<IdentityRoleDto>(
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(roles)
);
@ -55,7 +55,7 @@ namespace Volo.Abp.Identity
{
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id);
(await _userManager.CreateAsync(user, input.Password)).CheckErrors();
(await UserManager.CreateAsync(user, input.Password)).CheckErrors();
await UpdateUserByInput(user, input);
await CurrentUnitOfWork.SaveChangesAsync();
@ -66,17 +66,17 @@ namespace Volo.Abp.Identity
[Authorize(IdentityPermissions.Users.Update)]
public virtual async Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{
var user = await _userManager.GetByIdAsync(id);
var user = await UserManager.GetByIdAsync(id);
user.ConcurrencyStamp = input.ConcurrencyStamp;
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
(await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await UpdateUserByInput(user, input);
(await _userManager.UpdateAsync(user)).CheckErrors();
(await UserManager.UpdateAsync(user)).CheckErrors();
if (!input.Password.IsNullOrEmpty())
{
(await _userManager.RemovePasswordAsync(user)).CheckErrors();
(await _userManager.AddPasswordAsync(user, input.Password)).CheckErrors();
(await UserManager.RemovePasswordAsync(user)).CheckErrors();
(await UserManager.AddPasswordAsync(user, input.Password)).CheckErrors();
}
await CurrentUnitOfWork.SaveChangesAsync();
@ -92,28 +92,28 @@ namespace Volo.Abp.Identity
throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion);
}
var user = await _userManager.FindByIdAsync(id.ToString());
var user = await UserManager.FindByIdAsync(id.ToString());
if (user == null)
{
return;
}
(await _userManager.DeleteAsync(user)).CheckErrors();
(await UserManager.DeleteAsync(user)).CheckErrors();
}
[Authorize(IdentityPermissions.Users.Update)]
public virtual async Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input)
{
var user = await _userManager.GetByIdAsync(id);
(await _userManager.SetRolesAsync(user, input.RoleNames)).CheckErrors();
await _userRepository.UpdateAsync(user);
var user = await UserManager.GetByIdAsync(id);
(await UserManager.SetRolesAsync(user, input.RoleNames)).CheckErrors();
await UserRepository.UpdateAsync(user);
}
[Authorize(IdentityPermissions.Users.Default)]
public virtual async Task<IdentityUserDto> FindByUsernameAsync(string username)
{
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(
await _userManager.FindByNameAsync(username)
await UserManager.FindByNameAsync(username)
);
}
@ -121,31 +121,31 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityUserDto> FindByEmailAsync(string email)
{
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(
await _userManager.FindByEmailAsync(email)
await UserManager.FindByEmailAsync(email)
);
}
private async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input)
protected virtual async Task UpdateUserByInput(IdentityUser user, IdentityUserCreateOrUpdateDtoBase input)
{
if (!string.Equals(user.Email, input.Email, StringComparison.InvariantCultureIgnoreCase))
{
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();
(await UserManager.SetEmailAsync(user, input.Email)).CheckErrors();
}
if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase))
{
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
(await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
}
(await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors();
(await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors();
(await UserManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors();
(await UserManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors();
user.Name = input.Name;
user.Surname = input.Surname;
if (input.RoleNames != null)
{
(await _userManager.SetRolesAsync(user, input.RoleNames)).CheckErrors();
(await UserManager.SetRolesAsync(user, input.RoleNames)).CheckErrors();
}
}
}

20
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs

@ -10,40 +10,40 @@ namespace Volo.Abp.Identity
[Authorize]
public class ProfileAppService : IdentityAppServiceBase, IProfileAppService
{
private readonly IdentityUserManager _userManager;
protected IdentityUserManager UserManager { get; }
public ProfileAppService(IdentityUserManager userManager)
{
_userManager = userManager;
UserManager = userManager;
}
public virtual async Task<ProfileDto> GetAsync()
{
return ObjectMapper.Map<IdentityUser, ProfileDto>(
await _userManager.GetByIdAsync(CurrentUser.GetId())
await UserManager.GetByIdAsync(CurrentUser.GetId())
);
}
public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
{
var user = await _userManager.GetByIdAsync(CurrentUser.GetId());
var user = await UserManager.GetByIdAsync(CurrentUser.GetId());
if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled))
{
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
(await UserManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
}
if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled))
{
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();
(await UserManager.SetEmailAsync(user, input.Email)).CheckErrors();
}
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
(await UserManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
user.Name = input.Name;
user.Surname = input.Surname;
(await _userManager.UpdateAsync(user)).CheckErrors();
(await UserManager.UpdateAsync(user)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
@ -52,8 +52,8 @@ namespace Volo.Abp.Identity
public virtual async Task ChangePasswordAsync(ChangePasswordInput input)
{
var currentUser = await _userManager.GetByIdAsync(CurrentUser.GetId());
(await _userManager.ChangePasswordAsync(currentUser, input.CurrentPassword, input.NewPassword)).CheckErrors();
var currentUser = await UserManager.GetByIdAsync(CurrentUser.GetId());
(await UserManager.ChangePasswordAsync(currentUser, input.CurrentPassword, input.NewPassword)).CheckErrors();
}
}
}

30
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityOptionsFactory.cs

@ -12,7 +12,7 @@ namespace Volo.Abp.Identity
{
public class AbpIdentityOptionsFactory : AbpOptionsFactory<IdentityOptions>
{
private readonly ISettingProvider _settingProvider;
protected ISettingProvider SettingProvider { get; }
public AbpIdentityOptionsFactory(
IEnumerable<IConfigureOptions<IdentityOptions>> setups,
@ -20,7 +20,7 @@ namespace Volo.Abp.Identity
ISettingProvider settingProvider)
: base(setups, postConfigures)
{
_settingProvider = settingProvider;
SettingProvider = settingProvider;
}
public override IdentityOptions Create(string name)
@ -39,19 +39,19 @@ namespace Volo.Abp.Identity
protected virtual async Task OverrideOptionsAsync(IdentityOptions options)
{
options.Password.RequiredLength = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength);
options.Password.RequiredUniqueChars = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars);
options.Password.RequireNonAlphanumeric = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric);
options.Password.RequireLowercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase);
options.Password.RequireUppercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase);
options.Password.RequireDigit = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit);
options.Lockout.AllowedForNewUsers = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers);
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(await _settingProvider.GetAsync(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To<int>()));
options.Lockout.MaxFailedAccessAttempts = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts);
options.SignIn.RequireConfirmedEmail = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail);
options.SignIn.RequireConfirmedPhoneNumber = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber);
options.Password.RequiredLength = await SettingProvider.GetAsync(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength);
options.Password.RequiredUniqueChars = await SettingProvider.GetAsync(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars);
options.Password.RequireNonAlphanumeric = await SettingProvider.GetAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric);
options.Password.RequireLowercase = await SettingProvider.GetAsync(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase);
options.Password.RequireUppercase = await SettingProvider.GetAsync(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase);
options.Password.RequireDigit = await SettingProvider.GetAsync(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit);
options.Lockout.AllowedForNewUsers = await SettingProvider.GetAsync(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers);
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromSeconds(await SettingProvider.GetAsync(IdentitySettingNames.Lockout.LockoutDuration, options.Lockout.DefaultLockoutTimeSpan.TotalSeconds.To<int>()));
options.Lockout.MaxFailedAccessAttempts = await SettingProvider.GetAsync(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts);
options.SignIn.RequireConfirmedEmail = await SettingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail);
options.SignIn.RequireConfirmedPhoneNumber = await SettingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber);
}
}

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/AbpIdentityResultException.cs

@ -30,7 +30,7 @@ namespace Volo.Abp.Identity
}
public string LocalizeMessage(LocalizationContext context)
public virtual string LocalizeMessage(LocalizationContext context)
{
return IdentityResult.LocalizeErrors(context.LocalizerFactory.Create<IdentityResource>());
}

12
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityClaimTypeManager.cs

@ -6,26 +6,26 @@ namespace Volo.Abp.Identity
//TODO: Rename to IdentityClaimTypeManager in v2.0!
public class IdenityClaimTypeManager : DomainService
{
private readonly IIdentityClaimTypeRepository _identityClaimTypeRepository;
protected IIdentityClaimTypeRepository IdentityClaimTypeRepository { get; }
public IdenityClaimTypeManager(IIdentityClaimTypeRepository identityClaimTypeRepository)
{
_identityClaimTypeRepository = identityClaimTypeRepository;
IdentityClaimTypeRepository = identityClaimTypeRepository;
}
public virtual async Task<IdentityClaimType> CreateAsync(IdentityClaimType claimType)
{
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name))
if (await IdentityClaimTypeRepository.AnyAsync(claimType.Name))
{
throw new AbpException($"Name Exist: {claimType.Name}");
}
return await _identityClaimTypeRepository.InsertAsync(claimType);
return await IdentityClaimTypeRepository.InsertAsync(claimType);
}
public virtual async Task<IdentityClaimType> UpdateAsync(IdentityClaimType claimType)
{
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id))
if (await IdentityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id))
{
throw new AbpException($"Name Exist: {claimType.Name}");
}
@ -36,7 +36,7 @@ namespace Volo.Abp.Identity
}
return await _identityClaimTypeRepository.UpdateAsync(claimType);
return await IdentityClaimTypeRepository.UpdateAsync(claimType);
}
}
}

8
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeedContributor.cs

@ -6,16 +6,16 @@ namespace Volo.Abp.Identity
{
public class IdentityDataSeedContributor : IDataSeedContributor, ITransientDependency
{
private readonly IIdentityDataSeeder _identityDataSeeder;
protected IIdentityDataSeeder IdentityDataSeeder { get; }
public IdentityDataSeedContributor(IIdentityDataSeeder identityDataSeeder)
{
_identityDataSeeder = identityDataSeeder;
IdentityDataSeeder = identityDataSeeder;
}
public Task SeedAsync(DataSeedContext context)
public virtual Task SeedAsync(DataSeedContext context)
{
return _identityDataSeeder.SeedAsync(
return IdentityDataSeeder.SeedAsync(
context["AdminEmail"] as string ?? "admin@abp.io",
context["AdminPassword"] as string ?? "1q2w3E*",
context.TenantId

40
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityDataSeeder.cs

@ -9,12 +9,12 @@ namespace Volo.Abp.Identity
{
public class IdentityDataSeeder : ITransientDependency, IIdentityDataSeeder
{
private readonly IGuidGenerator _guidGenerator;
private readonly IIdentityRoleRepository _roleRepository;
private readonly IIdentityUserRepository _userRepository;
private readonly ILookupNormalizer _lookupNormalizer;
private readonly IdentityUserManager _userManager;
private readonly IdentityRoleManager _roleManager;
protected IGuidGenerator GuidGenerator { get; }
protected IIdentityRoleRepository RoleRepository { get; }
protected IIdentityUserRepository UserRepository { get; }
protected ILookupNormalizer LookupNormalizer { get; }
protected IdentityUserManager UserManager { get; }
protected IdentityRoleManager RoleManager { get; }
public IdentityDataSeeder(
IGuidGenerator guidGenerator,
@ -24,12 +24,12 @@ namespace Volo.Abp.Identity
IdentityUserManager userManager,
IdentityRoleManager roleManager)
{
_guidGenerator = guidGenerator;
_roleRepository = roleRepository;
_userRepository = userRepository;
_lookupNormalizer = lookupNormalizer;
_userManager = userManager;
_roleManager = roleManager;
GuidGenerator = guidGenerator;
RoleRepository = roleRepository;
UserRepository = userRepository;
LookupNormalizer = lookupNormalizer;
UserManager = userManager;
RoleManager = roleManager;
}
[UnitOfWork]
@ -45,8 +45,8 @@ namespace Volo.Abp.Identity
//"admin" user
const string adminUserName = "admin";
var adminUser = await _userRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.NormalizeName(adminUserName)
var adminUser = await UserRepository.FindByNormalizedUserNameAsync(
LookupNormalizer.NormalizeName(adminUserName)
);
if (adminUser != null)
@ -55,7 +55,7 @@ namespace Volo.Abp.Identity
}
adminUser = new IdentityUser(
_guidGenerator.Create(),
GuidGenerator.Create(),
adminUserName,
adminEmail,
tenantId
@ -64,16 +64,16 @@ namespace Volo.Abp.Identity
Name = adminUserName
};
(await _userManager.CreateAsync(adminUser, adminPassword)).CheckErrors();
(await UserManager.CreateAsync(adminUser, adminPassword)).CheckErrors();
result.CreatedAdminUser = true;
//"admin" role
const string adminRoleName = "admin";
var adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName(adminRoleName));
var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(adminRoleName));
if (adminRole == null)
{
adminRole = new IdentityRole(
_guidGenerator.Create(),
GuidGenerator.Create(),
adminRoleName,
tenantId
)
@ -82,11 +82,11 @@ namespace Volo.Abp.Identity
IsPublic = true
};
(await _roleManager.CreateAsync(adminRole)).CheckErrors();
(await RoleManager.CreateAsync(adminRole)).CheckErrors();
result.CreatedAdminRole = true;
}
(await _userManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors();
(await UserManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors();
return result;
}

14
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleManager.cs

@ -15,10 +15,10 @@ namespace Volo.Abp.Identity
{
public class IdentityRoleManager : RoleManager<IdentityRole>, IDomainService
{
protected override CancellationToken CancellationToken => _cancellationTokenProvider.Token;
protected override CancellationToken CancellationToken => CancellationTokenProvider.Token;
private readonly IStringLocalizer<IdentityResource> _localizer;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
protected IStringLocalizer<IdentityResource> Localizer { get; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
public IdentityRoleManager(
IdentityRoleStore store,
@ -35,8 +35,8 @@ namespace Volo.Abp.Identity
errors,
logger)
{
_localizer = localizer;
_cancellationTokenProvider = cancellationTokenProvider;
Localizer = localizer;
CancellationTokenProvider = cancellationTokenProvider;
}
public virtual async Task<IdentityRole> GetByIdAsync(Guid id)
@ -54,7 +54,7 @@ namespace Volo.Abp.Identity
{
if (role.IsStatic && role.Name != name)
{
throw new BusinessException(_localizer["Identity.StaticRoleRenamingErrorMessage"]); // TODO: localize & change exception type
throw new BusinessException(Localizer["Identity.StaticRoleRenamingErrorMessage"]); // TODO: localize & change exception type
}
return await base.SetRoleNameAsync(role, name);
@ -64,7 +64,7 @@ namespace Volo.Abp.Identity
{
if (role.IsStatic)
{
throw new BusinessException(_localizer["Identity.StaticRoleDeletionErrorMessage"]); // TODO: localize & change exception type
throw new BusinessException(Localizer["Identity.StaticRoleDeletionErrorMessage"]); // TODO: localize & change exception type
}
return await base.DeleteAsync(role);

48
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityRoleStore.cs

@ -22,9 +22,9 @@ namespace Volo.Abp.Identity
IRoleClaimStore<IdentityRole>,
ITransientDependency
{
private readonly IIdentityRoleRepository _roleRepository;
private readonly ILogger<IdentityRoleStore> _logger;
private readonly IGuidGenerator _guidGenerator;
protected IIdentityRoleRepository RoleRepository { get; }
protected ILogger<IdentityRoleStore> Logger { get; }
protected IGuidGenerator GuidGenerator { get; }
/// <summary>
/// Constructs a new instance of <see cref="IdentityRoleStore"/>.
@ -35,9 +35,9 @@ namespace Volo.Abp.Identity
IGuidGenerator guidGenerator,
IdentityErrorDescriber describer = null)
{
_roleRepository = roleRepository;
_logger = logger;
_guidGenerator = guidGenerator;
RoleRepository = roleRepository;
Logger = logger;
GuidGenerator = guidGenerator;
ErrorDescriber = describer ?? new IdentityErrorDescriber();
}
@ -67,7 +67,7 @@ namespace Volo.Abp.Identity
Check.NotNull(role, nameof(role));
await _roleRepository.InsertAsync(role, AutoSaveChanges, cancellationToken);
await RoleRepository.InsertAsync(role, AutoSaveChanges, cancellationToken);
return IdentityResult.Success;
}
@ -86,11 +86,11 @@ namespace Volo.Abp.Identity
try
{
await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken);
await RoleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken);
}
catch (AbpDbConcurrencyException ex)
{
_logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
Logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
return IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure());
}
@ -111,11 +111,11 @@ namespace Volo.Abp.Identity
try
{
await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken);
await RoleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken);
}
catch (AbpDbConcurrencyException ex)
{
_logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
Logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
return IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure());
}
@ -128,7 +128,7 @@ namespace Volo.Abp.Identity
/// <param name="role">The role whose ID should be returned.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the ID of the role.</returns>
public Task<string> GetRoleIdAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
public virtual Task<string> GetRoleIdAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@ -143,7 +143,7 @@ namespace Volo.Abp.Identity
/// <param name="role">The role whose name should be returned.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the name of the role.</returns>
public Task<string> GetRoleNameAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
public virtual Task<string> GetRoleNameAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@ -159,7 +159,7 @@ namespace Volo.Abp.Identity
/// <param name="roleName">The name of the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public Task SetRoleNameAsync([NotNull] IdentityRole role, string roleName, CancellationToken cancellationToken = default)
public virtual Task SetRoleNameAsync([NotNull] IdentityRole role, string roleName, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
@ -179,7 +179,7 @@ namespace Volo.Abp.Identity
{
cancellationToken.ThrowIfCancellationRequested();
return _roleRepository.FindAsync(Guid.Parse(id), cancellationToken: cancellationToken);
return RoleRepository.FindAsync(Guid.Parse(id), cancellationToken: cancellationToken);
}
/// <summary>
@ -194,7 +194,7 @@ namespace Volo.Abp.Identity
Check.NotNull(normalizedName, nameof(normalizedName));
return _roleRepository.FindByNormalizedNameAsync(normalizedName, cancellationToken: cancellationToken);
return RoleRepository.FindByNormalizedNameAsync(normalizedName, cancellationToken: cancellationToken);
}
/// <summary>
@ -233,7 +233,7 @@ namespace Volo.Abp.Identity
/// <summary>
/// Dispose the stores
/// </summary>
public void Dispose()
public virtual void Dispose()
{
}
@ -243,13 +243,13 @@ namespace Volo.Abp.Identity
/// <param name="role">The role whose claims should be retrieved.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>A <see cref="Task{TResult}"/> that contains the claims granted to a role.</returns>
public async Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
public virtual async Task<IList<Claim>> GetClaimsAsync([NotNull] IdentityRole role, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(role, nameof(role));
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
await RoleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
return role.Claims.Select(c => c.ToClaim()).ToList();
}
@ -261,16 +261,16 @@ namespace Volo.Abp.Identity
/// <param name="claim">The claim to add to the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task AddClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default)
public virtual async Task AddClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(role, nameof(role));
Check.NotNull(claim, nameof(claim));
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
await RoleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
role.AddClaim(_guidGenerator, claim);
role.AddClaim(GuidGenerator, claim);
}
/// <summary>
@ -280,12 +280,12 @@ namespace Volo.Abp.Identity
/// <param name="claim">The claim to remove from the role.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task RemoveClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default)
public virtual async Task RemoveClaimAsync([NotNull] IdentityRole role, [NotNull] Claim claim, CancellationToken cancellationToken = default)
{
Check.NotNull(role, nameof(role));
Check.NotNull(claim, nameof(claim));
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
await RoleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
role.RemoveClaim(claim);
}

2
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserLogin.cs

@ -68,7 +68,7 @@ namespace Volo.Abp.Identity
{
}
public UserLoginInfo ToUserLoginInfo()
public virtual UserLoginInfo ToUserLoginInfo()
{
return new UserLoginInfo(LoginProvider, ProviderKey, ProviderDisplayName);
}

6
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserManager.cs

@ -19,9 +19,9 @@ namespace Volo.Abp.Identity
protected IIdentityRoleRepository RoleRepository { get; }
protected IIdentityUserRepository UserRepository { get; }
protected override CancellationToken CancellationToken => _cancellationTokenProvider.Token;
protected override CancellationToken CancellationToken => CancellationTokenProvider.Token;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
protected ICancellationTokenProvider CancellationTokenProvider { get; }
public IdentityUserManager(
IdentityUserStore store,
@ -49,7 +49,7 @@ namespace Volo.Abp.Identity
{
RoleRepository = roleRepository;
UserRepository = userRepository;
_cancellationTokenProvider = cancellationTokenProvider;
CancellationTokenProvider = cancellationTokenProvider;
}
public virtual async Task<IdentityUser> GetByIdAsync(Guid id)

32
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserRepositoryExternalUserLookupServiceProvider.cs

@ -9,15 +9,15 @@ namespace Volo.Abp.Identity
{
public class IdentityUserRepositoryExternalUserLookupServiceProvider : IExternalUserLookupServiceProvider, ITransientDependency
{
private readonly IIdentityUserRepository _userRepository;
private readonly ILookupNormalizer _lookupNormalizer;
protected IIdentityUserRepository UserRepository { get; }
protected ILookupNormalizer LookupNormalizer { get; }
public IdentityUserRepositoryExternalUserLookupServiceProvider(
IIdentityUserRepository userRepository,
ILookupNormalizer lookupNormalizer)
{
_userRepository = userRepository;
_lookupNormalizer = lookupNormalizer;
UserRepository = userRepository;
LookupNormalizer = lookupNormalizer;
}
public virtual async Task<IUserData> FindByIdAsync(
@ -25,12 +25,12 @@ namespace Volo.Abp.Identity
CancellationToken cancellationToken = default)
{
return (
await _userRepository.FindAsync(
id,
includeDetails: false,
cancellationToken: cancellationToken
)
)?.ToAbpUserData();
await UserRepository.FindAsync(
id,
includeDetails: false,
cancellationToken: cancellationToken
)
)?.ToAbpUserData();
}
public virtual async Task<IUserData> FindByUserNameAsync(
@ -38,12 +38,12 @@ namespace Volo.Abp.Identity
CancellationToken cancellationToken = default)
{
return (
await _userRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.NormalizeName(userName),
includeDetails: false,
cancellationToken: cancellationToken
)
)?.ToAbpUserData();
await UserRepository.FindByNormalizedUserNameAsync(
LookupNormalizer.NormalizeName(userName),
includeDetails: false,
cancellationToken: cancellationToken
)
)?.ToAbpUserData();
}
}
}

84
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/IdentityUserStore.cs

@ -50,10 +50,10 @@ namespace Volo.Abp.Identity
/// </value>
public bool AutoSaveChanges { get; set; } = true;
private readonly IIdentityRoleRepository _roleRepository;
private readonly IGuidGenerator _guidGenerator;
private readonly ILogger<IdentityRoleStore> _logger;
private readonly IIdentityUserRepository _userRepository;
protected IIdentityRoleRepository RoleRepository { get; }
protected IGuidGenerator GuidGenerator { get; }
protected ILogger<IdentityRoleStore> Logger { get; }
protected IIdentityUserRepository UserRepository { get; }
public IdentityUserStore(
IIdentityUserRepository userRepository,
@ -62,10 +62,10 @@ namespace Volo.Abp.Identity
ILogger<IdentityRoleStore> logger,
IdentityErrorDescriber describer = null)
{
_userRepository = userRepository;
_roleRepository = roleRepository;
_guidGenerator = guidGenerator;
_logger = logger;
UserRepository = userRepository;
RoleRepository = roleRepository;
GuidGenerator = guidGenerator;
Logger = logger;
ErrorDescriber = describer ?? new IdentityErrorDescriber();
}
@ -163,7 +163,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
await _userRepository.InsertAsync(user, AutoSaveChanges, cancellationToken);
await UserRepository.InsertAsync(user, AutoSaveChanges, cancellationToken);
return IdentityResult.Success;
}
@ -182,11 +182,11 @@ namespace Volo.Abp.Identity
try
{
await _userRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken);
await UserRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken);
}
catch (AbpDbConcurrencyException ex)
{
_logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
Logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
return IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure());
}
@ -207,11 +207,11 @@ namespace Volo.Abp.Identity
try
{
await _userRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken);
await UserRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken);
}
catch (AbpDbConcurrencyException ex)
{
_logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
Logger.LogWarning(ex.ToString()); //Trigger some AbpHandledException event
return IdentityResult.Failed(ErrorDescriber.ConcurrencyFailure());
}
@ -230,7 +230,7 @@ namespace Volo.Abp.Identity
{
cancellationToken.ThrowIfCancellationRequested();
return _userRepository.FindAsync(Guid.Parse(userId), cancellationToken: cancellationToken);
return UserRepository.FindAsync(Guid.Parse(userId), cancellationToken: cancellationToken);
}
/// <summary>
@ -247,7 +247,7 @@ namespace Volo.Abp.Identity
Check.NotNull(normalizedUserName, nameof(normalizedUserName));
return _userRepository.FindByNormalizedUserNameAsync(normalizedUserName, includeDetails: false, cancellationToken: cancellationToken);
return UserRepository.FindByNormalizedUserNameAsync(normalizedUserName, includeDetails: false, cancellationToken: cancellationToken);
}
/// <summary>
@ -313,14 +313,14 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
Check.NotNull(normalizedRoleName, nameof(normalizedRoleName));
var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
var role = await RoleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
if (role == null)
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Role {0} does not exist!", normalizedRoleName));
}
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
user.AddRole(role.Id);
}
@ -343,13 +343,13 @@ namespace Volo.Abp.Identity
throw new ArgumentException(nameof(normalizedRoleName) + " can not be null or whitespace");
}
var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
var role = await RoleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
if (role == null)
{
return;
}
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
user.RemoveRole(role.Id);
}
@ -366,7 +366,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
return await _userRepository.GetRoleNamesAsync(user.Id, cancellationToken: cancellationToken);
return await UserRepository.GetRoleNamesAsync(user.Id, cancellationToken: cancellationToken);
}
/// <summary>
@ -388,13 +388,13 @@ namespace Volo.Abp.Identity
throw new ArgumentException(nameof(normalizedRoleName) + " can not be null or whitespace");
}
var role = await _roleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
var role = await RoleRepository.FindByNormalizedNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
if (role == null)
{
return false;
}
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
return user.IsInRole(role.Id);
}
@ -411,7 +411,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
return user.Claims.Select(c => c.ToClaim()).ToList();
}
@ -430,9 +430,9 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
Check.NotNull(claims, nameof(claims));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
user.AddClaims(_guidGenerator, claims);
user.AddClaims(GuidGenerator, claims);
}
/// <summary>
@ -451,7 +451,7 @@ namespace Volo.Abp.Identity
Check.NotNull(claim, nameof(claim));
Check.NotNull(newClaim, nameof(newClaim));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
user.ReplaceClaim(claim, newClaim);
}
@ -470,7 +470,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
Check.NotNull(claims, nameof(claims));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Claims, cancellationToken);
user.RemoveClaims(claims);
}
@ -489,7 +489,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
Check.NotNull(login, nameof(login));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
user.AddLogin(login);
}
@ -510,7 +510,7 @@ namespace Volo.Abp.Identity
Check.NotNull(loginProvider, nameof(loginProvider));
Check.NotNull(providerKey, nameof(providerKey));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
user.RemoveLogin(loginProvider, providerKey);
}
@ -529,7 +529,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Logins, cancellationToken);
return user.Logins.Select(l => l.ToUserLoginInfo()).ToList();
}
@ -550,7 +550,7 @@ namespace Volo.Abp.Identity
Check.NotNull(loginProvider, nameof(loginProvider));
Check.NotNull(providerKey, nameof(providerKey));
return _userRepository.FindByLoginAsync(loginProvider, providerKey, cancellationToken: cancellationToken);
return UserRepository.FindByLoginAsync(loginProvider, providerKey, cancellationToken: cancellationToken);
}
/// <summary>
@ -671,7 +671,7 @@ namespace Volo.Abp.Identity
{
cancellationToken.ThrowIfCancellationRequested();
return _userRepository.FindByNormalizedEmailAsync(normalizedEmail, includeDetails: false, cancellationToken: cancellationToken);
return UserRepository.FindByNormalizedEmailAsync(normalizedEmail, includeDetails: false, cancellationToken: cancellationToken);
}
/// <summary>
@ -950,7 +950,7 @@ namespace Volo.Abp.Identity
Check.NotNull(claim, nameof(claim));
return await _userRepository.GetListByClaimAsync(claim, cancellationToken: cancellationToken);
return await UserRepository.GetListByClaimAsync(claim, cancellationToken: cancellationToken);
}
/// <summary>
@ -970,7 +970,7 @@ namespace Volo.Abp.Identity
throw new ArgumentNullException(nameof(normalizedRoleName));
}
return await _userRepository.GetListByNormalizedRoleNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
return await UserRepository.GetListByNormalizedRoleNameAsync(normalizedRoleName, cancellationToken: cancellationToken);
}
/// <summary>
@ -988,7 +988,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
user.SetToken(loginProvider, name, value);
}
@ -1001,13 +1001,13 @@ namespace Volo.Abp.Identity
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken = default)
public virtual async Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
user.RemoveToken(loginProvider, name);
}
@ -1020,23 +1020,23 @@ namespace Volo.Abp.Identity
/// <param name="name">The name of the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> used to propagate notifications that the operation should be canceled.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous operation.</returns>
public async Task<string> GetTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken = default)
public virtual async Task<string> GetTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken = default)
{
cancellationToken.ThrowIfCancellationRequested();
Check.NotNull(user, nameof(user));
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
await UserRepository.EnsureCollectionLoadedAsync(user, u => u.Tokens, cancellationToken);
return user.FindToken(loginProvider, name)?.Value;
}
public Task SetAuthenticatorKeyAsync(IdentityUser user, string key, CancellationToken cancellationToken = default)
public virtual Task SetAuthenticatorKeyAsync(IdentityUser user, string key, CancellationToken cancellationToken = default)
{
return SetTokenAsync(user, InternalLoginProvider, AuthenticatorKeyTokenName, key, cancellationToken);
}
public Task<string> GetAuthenticatorKeyAsync(IdentityUser user, CancellationToken cancellationToken = default)
public virtual Task<string> GetAuthenticatorKeyAsync(IdentityUser user, CancellationToken cancellationToken = default)
{
return GetTokenAsync(user, InternalLoginProvider, AuthenticatorKeyTokenName, cancellationToken);
}
@ -1101,7 +1101,7 @@ namespace Volo.Abp.Identity
return false;
}
public void Dispose()
public virtual void Dispose()
{
}

6
modules/identity/src/Volo.Abp.Identity.Domain/Volo/Abp/Identity/UserRoleFinder.cs

@ -6,16 +6,16 @@ namespace Volo.Abp.Identity
{
public class UserRoleFinder : IUserRoleFinder, ITransientDependency
{
private readonly IIdentityUserRepository _identityUserRepository;
protected IIdentityUserRepository IdentityUserRepository { get; }
public UserRoleFinder(IIdentityUserRepository identityUserRepository)
{
_identityUserRepository = identityUserRepository;
IdentityUserRepository = identityUserRepository;
}
public virtual async Task<string[]> GetRolesAsync(Guid userId)
{
return (await _identityUserRepository.GetRoleNamesAsync(userId)).ToArray();
return (await IdentityUserRepository.GetRoleNamesAsync(userId)).ToArray();
}
}
}

4
modules/identity/src/Volo.Abp.Identity.EntityFrameworkCore/Volo/Abp/Identity/EntityFrameworkCore/EfCoreIdentityClaimTypeRepository.cs

@ -17,14 +17,14 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
}
public async Task<bool> AnyAsync(string name, Guid? ignoredId = null)
public virtual async Task<bool> AnyAsync(string name, Guid? ignoredId = null)
{
return await DbSet
.WhereIf(ignoredId != null, ct => ct.Id != ignoredId)
.CountAsync(ct => ct.Name == name) > 0;
}
public async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter)
public virtual async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter)
{
var identityClaimTypes = await DbSet
.WhereIf(

12
modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientIdentityUserLookupService.cs

@ -9,21 +9,21 @@ namespace Volo.Abp.Identity
[Dependency(TryRegister = true)]
public class HttpClientExternalUserLookupServiceProvider : IExternalUserLookupServiceProvider, ITransientDependency
{
private readonly IIdentityUserLookupAppService _userLookupAppService;
protected IIdentityUserLookupAppService UserLookupAppService { get; }
public HttpClientExternalUserLookupServiceProvider(IIdentityUserLookupAppService userLookupAppService)
{
_userLookupAppService = userLookupAppService;
UserLookupAppService = userLookupAppService;
}
public async Task<IUserData> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
public virtual async Task<IUserData> FindByIdAsync(Guid id, CancellationToken cancellationToken = default)
{
return await _userLookupAppService.FindByIdAsync(id);
return await UserLookupAppService.FindByIdAsync(id);
}
public async Task<IUserData> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
public virtual async Task<IUserData> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default)
{
return await _userLookupAppService.FindByUserNameAsync(userName);
return await UserLookupAppService.FindByUserNameAsync(userName);
}
}
}

4
modules/identity/src/Volo.Abp.Identity.HttpApi.Client/Volo/Abp/Identity/HttpClientUserRoleFinder.cs

@ -8,14 +8,14 @@ namespace Volo.Abp.Identity
[Dependency(TryRegister = true)]
public class HttpClientUserRoleFinder : IUserRoleFinder, ITransientDependency
{
private readonly IIdentityUserAppService _userAppService;
protected IIdentityUserAppService _userAppService { get; }
public HttpClientUserRoleFinder(IIdentityUserAppService userAppService)
{
_userAppService = userAppService;
}
public async Task<string[]> GetRolesAsync(Guid userId)
public virtual async Task<string[]> GetRolesAsync(Guid userId)
{
var output = await _userAppService.GetRolesAsync(userId);
return output.Items.Select(r => r.Name).ToArray();

16
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs

@ -13,51 +13,51 @@ namespace Volo.Abp.Identity
[Route("api/identity/roles")]
public class IdentityRoleController : AbpController, IIdentityRoleAppService
{
private readonly IIdentityRoleAppService _roleAppService;
protected IIdentityRoleAppService RoleAppService { get; }
public IdentityRoleController(IIdentityRoleAppService roleAppService)
{
_roleAppService = roleAppService;
RoleAppService = roleAppService;
}
[HttpGet]
[Route("all")]
public virtual Task<ListResultDto<IdentityRoleDto>> GetAllListAsync()
{
return _roleAppService.GetAllListAsync();
return RoleAppService.GetAllListAsync();
}
[HttpGet]
public virtual Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input)
{
return _roleAppService.GetListAsync(input);
return RoleAppService.GetListAsync(input);
}
[HttpGet]
[Route("{id}")]
public virtual Task<IdentityRoleDto> GetAsync(Guid id)
{
return _roleAppService.GetAsync(id);
return RoleAppService.GetAsync(id);
}
[HttpPost]
public virtual Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input)
{
return _roleAppService.CreateAsync(input);
return RoleAppService.CreateAsync(input);
}
[HttpPut]
[Route("{id}")]
public virtual Task<IdentityRoleDto> UpdateAsync(Guid id, IdentityRoleUpdateDto input)
{
return _roleAppService.UpdateAsync(id, input);
return RoleAppService.UpdateAsync(id, input);
}
[HttpDelete]
[Route("{id}")]
public virtual Task DeleteAsync(Guid id)
{
return _roleAppService.DeleteAsync(id);
return RoleAppService.DeleteAsync(id);
}
}
}

22
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs

@ -12,72 +12,72 @@ namespace Volo.Abp.Identity
[Route("api/identity/users")]
public class IdentityUserController : AbpController, IIdentityUserAppService
{
private readonly IIdentityUserAppService _userAppService;
protected IIdentityUserAppService UserAppService { get; }
public IdentityUserController(IIdentityUserAppService userAppService)
{
_userAppService = userAppService;
UserAppService = userAppService;
}
[HttpGet]
[Route("{id}")]
public virtual Task<IdentityUserDto> GetAsync(Guid id)
{
return _userAppService.GetAsync(id);
return UserAppService.GetAsync(id);
}
[HttpGet]
public virtual Task<PagedResultDto<IdentityUserDto>> GetListAsync(GetIdentityUsersInput input)
{
return _userAppService.GetListAsync(input);
return UserAppService.GetListAsync(input);
}
[HttpPost]
public virtual Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
{
return _userAppService.CreateAsync(input);
return UserAppService.CreateAsync(input);
}
[HttpPut]
[Route("{id}")]
public virtual Task<IdentityUserDto> UpdateAsync(Guid id, IdentityUserUpdateDto input)
{
return _userAppService.UpdateAsync(id, input);
return UserAppService.UpdateAsync(id, input);
}
[HttpDelete]
[Route("{id}")]
public virtual Task DeleteAsync(Guid id)
{
return _userAppService.DeleteAsync(id);
return UserAppService.DeleteAsync(id);
}
[HttpGet]
[Route("{id}/roles")]
public virtual Task<ListResultDto<IdentityRoleDto>> GetRolesAsync(Guid id)
{
return _userAppService.GetRolesAsync(id);
return UserAppService.GetRolesAsync(id);
}
[HttpPut]
[Route("{id}/roles")]
public virtual Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input)
{
return _userAppService.UpdateRolesAsync(id, input);
return UserAppService.UpdateRolesAsync(id, input);
}
[HttpGet]
[Route("by-username/{userName}")]
public virtual Task<IdentityUserDto> FindByUsernameAsync(string username)
{
return _userAppService.FindByUsernameAsync(username);
return UserAppService.FindByUsernameAsync(username);
}
[HttpGet]
[Route("by-email/{email}")]
public virtual Task<IdentityUserDto> FindByEmailAsync(string email)
{
return _userAppService.FindByEmailAsync(email);
return UserAppService.FindByEmailAsync(email);
}
}
}

4
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserLookupController.cs

@ -21,14 +21,14 @@ namespace Volo.Abp.Identity
[HttpGet]
[Route("{id}")]
public Task<UserData> FindByIdAsync(Guid id)
public virtual Task<UserData> FindByIdAsync(Guid id)
{
return LookupAppService.FindByIdAsync(id);
}
[HttpGet]
[Route("by-username/{userName}")]
public Task<UserData> FindByUserNameAsync(string userName)
public virtual Task<UserData> FindByUserNameAsync(string userName)
{
return LookupAppService.FindByUserNameAsync(userName);
}

16
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/ProfileController.cs

@ -10,30 +10,30 @@ namespace Volo.Abp.Identity
[Route("/api/identity/my-profile")]
public class ProfileController : AbpController, IProfileAppService
{
private readonly IProfileAppService _profileAppService;
protected IProfileAppService ProfileAppService { get; }
public ProfileController(IProfileAppService profileAppService)
{
_profileAppService = profileAppService;
ProfileAppService = profileAppService;
}
[HttpGet]
public Task<ProfileDto> GetAsync()
public virtual Task<ProfileDto> GetAsync()
{
return _profileAppService.GetAsync();
return ProfileAppService.GetAsync();
}
[HttpPut]
public Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
public virtual Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
{
return _profileAppService.UpdateAsync(input);
return ProfileAppService.UpdateAsync(input);
}
[HttpPost]
[Route("change-password")]
public Task ChangePasswordAsync(ChangePasswordInput input)
public virtual Task ChangePasswordAsync(ChangePasswordInput input)
{
return _profileAppService.ChangePasswordAsync(input);
return ProfileAppService.ChangePasswordAsync(input);
}
}
}

4
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityClaimTypeRepository.cs

@ -16,7 +16,7 @@ namespace Volo.Abp.Identity.MongoDB
{
}
public async Task<bool> AnyAsync(string name, Guid? ignoredId = null)
public virtual async Task<bool> AnyAsync(string name, Guid? ignoredId = null)
{
if (ignoredId == null)
{
@ -32,7 +32,7 @@ namespace Volo.Abp.Identity.MongoDB
}
}
public async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter)
public virtual async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter)
{
return await GetMongoQueryable()
.WhereIf<IdentityClaimType, IMongoQueryable<IdentityClaimType>>(

5
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityRoleRepository.cs

@ -14,12 +14,9 @@ namespace Volo.Abp.Identity.MongoDB
{
public class MongoIdentityRoleRepository : MongoDbRepository<IAbpIdentityMongoDbContext, IdentityRole, Guid>, IIdentityRoleRepository
{
private readonly IGuidGenerator _guidGenerator;
public MongoIdentityRoleRepository(IMongoDbContextProvider<IAbpIdentityMongoDbContext> dbContextProvider, IGuidGenerator guidGenerator)
public MongoIdentityRoleRepository(IMongoDbContextProvider<IAbpIdentityMongoDbContext> dbContextProvider)
: base(dbContextProvider)
{
_guidGenerator = guidGenerator;
}
public async Task<IdentityRole> FindByNormalizedNameAsync(

23
modules/identity/src/Volo.Abp.Identity.MongoDB/Volo/Abp/Identity/MongoDB/MongoIdentityUserRepository.cs

@ -15,15 +15,12 @@ namespace Volo.Abp.Identity.MongoDB
{
public class MongoIdentityUserRepository : MongoDbRepository<IAbpIdentityMongoDbContext, IdentityUser, Guid>, IIdentityUserRepository
{
private readonly IGuidGenerator _guidGenerator;
public MongoIdentityUserRepository(IMongoDbContextProvider<IAbpIdentityMongoDbContext> dbContextProvider, IGuidGenerator guidGenerator)
public MongoIdentityUserRepository(IMongoDbContextProvider<IAbpIdentityMongoDbContext> dbContextProvider)
: base(dbContextProvider)
{
_guidGenerator = guidGenerator;
}
public async Task<IdentityUser> FindByNormalizedUserNameAsync(
public virtual async Task<IdentityUser> FindByNormalizedUserNameAsync(
string normalizedUserName,
bool includeDetails = true,
CancellationToken cancellationToken = default)
@ -35,7 +32,7 @@ namespace Volo.Abp.Identity.MongoDB
);
}
public async Task<List<string>> GetRoleNamesAsync(
public virtual async Task<List<string>> GetRoleNamesAsync(
Guid id,
CancellationToken cancellationToken = default)
{
@ -44,7 +41,7 @@ namespace Volo.Abp.Identity.MongoDB
return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<IdentityUser> FindByLoginAsync(
public virtual async Task<IdentityUser> FindByLoginAsync(
string loginProvider,
string providerKey,
bool includeDetails = true,
@ -55,7 +52,7 @@ namespace Volo.Abp.Identity.MongoDB
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
}
public async Task<IdentityUser> FindByNormalizedEmailAsync(
public virtual async Task<IdentityUser> FindByNormalizedEmailAsync(
string normalizedEmail,
bool includeDetails = true,
CancellationToken cancellationToken = default)
@ -63,7 +60,7 @@ namespace Volo.Abp.Identity.MongoDB
return await GetMongoQueryable().FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityUser>> GetListByClaimAsync(
public virtual async Task<List<IdentityUser>> GetListByClaimAsync(
Claim claim,
bool includeDetails = false,
CancellationToken cancellationToken = default)
@ -73,7 +70,7 @@ namespace Volo.Abp.Identity.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync(
public virtual async Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync(
string normalizedRoleName,
bool includeDetails = false,
CancellationToken cancellationToken = default)
@ -90,7 +87,7 @@ namespace Volo.Abp.Identity.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityUser>> GetListAsync(
public virtual async Task<List<IdentityUser>> GetListAsync(
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
@ -111,7 +108,7 @@ namespace Volo.Abp.Identity.MongoDB
.ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<List<IdentityRole>> GetRolesAsync(
public virtual async Task<List<IdentityRole>> GetRolesAsync(
Guid id,
bool includeDetails = false,
CancellationToken cancellationToken = default)
@ -121,7 +118,7 @@ namespace Volo.Abp.Identity.MongoDB
return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).ToListAsync(GetCancellationToken(cancellationToken));
}
public async Task<long> GetCountAsync(
public virtual async Task<long> GetCountAsync(
string filter = null,
CancellationToken cancellationToken = default)
{

4
modules/identity/src/Volo.Abp.Identity.Web/AbpIdentityWebAutoMapperProfile.cs

@ -14,7 +14,7 @@ namespace Volo.Abp.Identity.Web
CreateRoleMappings();
}
private void CreateUserMappings()
protected virtual void CreateUserMappings()
{
//List
CreateMap<IdentityUserDto, EditUserModalModel.UserInfoViewModel>()
@ -35,7 +35,7 @@ namespace Volo.Abp.Identity.Web
.ForMember(dest => dest.IsAssigned, opt => opt.Ignore());
}
private void CreateRoleMappings()
protected virtual void CreateRoleMappings()
{
//List
CreateMap<IdentityRoleDto, EditModalModel.RoleInfoModel>();

2
modules/identity/src/Volo.Abp.Identity.Web/Navigation/AbpIdentityWebMainMenuContributor.cs

@ -9,7 +9,7 @@ namespace Volo.Abp.Identity.Web.Navigation
{
public class AbpIdentityWebMainMenuContributor : IMenuContributor
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
public virtual async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name != StandardMenus.Main)
{

6
modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RolePermissionManagementProvider.cs

@ -11,7 +11,7 @@ namespace Volo.Abp.PermissionManagement.Identity
{
public override string Name => RolePermissionValueProvider.ProviderName;
private readonly IUserRoleFinder _userRoleFinder;
protected IUserRoleFinder UserRoleFinder { get; }
public RolePermissionManagementProvider(
IPermissionGrantRepository permissionGrantRepository,
@ -23,7 +23,7 @@ namespace Volo.Abp.PermissionManagement.Identity
guidGenerator,
currentTenant)
{
_userRoleFinder = userRoleFinder;
UserRoleFinder = userRoleFinder;
}
public override async Task<PermissionValueProviderGrantInfo> CheckAsync(string name, string providerName, string providerKey)
@ -39,7 +39,7 @@ namespace Volo.Abp.PermissionManagement.Identity
if (providerName == UserPermissionValueProvider.ProviderName)
{
var userId = Guid.Parse(providerKey);
var roleNames = await _userRoleFinder.GetRolesAsync(userId);
var roleNames = await UserRoleFinder.GetRolesAsync(userId);
foreach (var roleName in roleNames)
{

2
modules/identity/src/Volo.Abp.PermissionManagement.Domain.Identity/Volo/Abp/PermissionManagement/Identity/RoleUpdateEventHandler.cs

@ -25,7 +25,7 @@ namespace Volo.Abp.PermissionManagement.Identity
PermissionGrantRepository = permissionGrantRepository;
}
public async Task HandleEventAsync(IdentityRoleNameChangedEvent eventData)
public virtual async Task HandleEventAsync(IdentityRoleNameChangedEvent eventData)
{
var role = await RoleRepository.FindAsync(eventData.IdentityRole.Id, false);
if (role == null)

Loading…
Cancel
Save