feat: add ConfigureAwait(false) to all await calls

pull/2500/head
Javier Campos 5 years ago
parent 2f7af82fc1
commit ad85526379

@ -24,14 +24,13 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityRoleDto> GetAsync(Guid id)
{
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(
await _roleManager.GetByIdAsync(id)
);
await _roleManager.GetByIdAsync(id).ConfigureAwait(false));
}
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).ConfigureAwait(false);
var totalCount = await _roleRepository.GetCountAsync().ConfigureAwait(false);
return new PagedResultDto<IdentityRoleDto>(
totalCount,
@ -47,8 +46,8 @@ namespace Volo.Abp.Identity
role.IsDefault = input.IsDefault;
role.IsPublic = input.IsPublic;
(await _roleManager.CreateAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
(await _roleManager.CreateAsync(role).ConfigureAwait(false)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
}
@ -56,16 +55,16 @@ 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).ConfigureAwait(false);
role.ConcurrencyStamp = input.ConcurrencyStamp;
(await _roleManager.SetRoleNameAsync(role, input.Name)).CheckErrors();
(await _roleManager.SetRoleNameAsync(role, input.Name).ConfigureAwait(false)).CheckErrors();
role.IsDefault = input.IsDefault;
role.IsPublic = input.IsPublic;
(await _roleManager.UpdateAsync(role)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
(await _roleManager.UpdateAsync(role).ConfigureAwait(false)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
return ObjectMapper.Map<IdentityRole, IdentityRoleDto>(role);
}
@ -73,13 +72,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()).ConfigureAwait(false);
if (role == null)
{
return;
}
(await _roleManager.DeleteAsync(role)).CheckErrors();
(await _roleManager.DeleteAsync(role).ConfigureAwait(false)).CheckErrors();
}
}
}

@ -26,14 +26,14 @@ namespace Volo.Abp.Identity
{
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(
await _userManager.GetByIdAsync(id)
);
.ConfigureAwait(false));
}
[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).ConfigureAwait(false);
var list = await _userRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter).ConfigureAwait(false);
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).ConfigureAwait(false);
return new ListResultDto<IdentityRoleDto>(
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(roles)
);
@ -55,10 +55,10 @@ namespace Volo.Abp.Identity
{
var user = new IdentityUser(GuidGenerator.Create(), input.UserName, input.Email, CurrentTenant.Id);
(await _userManager.CreateAsync(user, input.Password)).CheckErrors();
await UpdateUserByInput(user, input);
(await _userManager.CreateAsync(user, input.Password).ConfigureAwait(false)).CheckErrors();
await UpdateUserByInput(user, input).ConfigureAwait(false);
await CurrentUnitOfWork.SaveChangesAsync();
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}
@ -66,20 +66,20 @@ 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).ConfigureAwait(false);
user.ConcurrencyStamp = input.ConcurrencyStamp;
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
await UpdateUserByInput(user, input);
(await _userManager.UpdateAsync(user)).CheckErrors();
(await _userManager.SetUserNameAsync(user, input.UserName).ConfigureAwait(false)).CheckErrors();
await UpdateUserByInput(user, input).ConfigureAwait(false);
(await _userManager.UpdateAsync(user).ConfigureAwait(false)).CheckErrors();
if (!input.Password.IsNullOrEmpty())
{
(await _userManager.RemovePasswordAsync(user)).CheckErrors();
(await _userManager.AddPasswordAsync(user, input.Password)).CheckErrors();
(await _userManager.RemovePasswordAsync(user).ConfigureAwait(false)).CheckErrors();
(await _userManager.AddPasswordAsync(user, input.Password).ConfigureAwait(false)).CheckErrors();
}
await CurrentUnitOfWork.SaveChangesAsync();
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(user);
}
@ -92,21 +92,21 @@ namespace Volo.Abp.Identity
throw new BusinessException(code: IdentityErrorCodes.UserSelfDeletion);
}
var user = await _userManager.FindByIdAsync(id.ToString());
var user = await _userManager.FindByIdAsync(id.ToString()).ConfigureAwait(false);
if (user == null)
{
return;
}
(await _userManager.DeleteAsync(user)).CheckErrors();
(await _userManager.DeleteAsync(user).ConfigureAwait(false)).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).ConfigureAwait(false);
(await _userManager.SetRolesAsync(user, input.RoleNames).ConfigureAwait(false)).CheckErrors();
await _userRepository.UpdateAsync(user).ConfigureAwait(false);
}
[Authorize(IdentityPermissions.Users.Default)]
@ -114,7 +114,7 @@ namespace Volo.Abp.Identity
{
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(
await _userManager.FindByNameAsync(username)
);
.ConfigureAwait(false));
}
[Authorize(IdentityPermissions.Users.Default)]
@ -122,30 +122,30 @@ namespace Volo.Abp.Identity
{
return ObjectMapper.Map<IdentityUser, IdentityUserDto>(
await _userManager.FindByEmailAsync(email)
);
.ConfigureAwait(false));
}
private 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).ConfigureAwait(false)).CheckErrors();
}
if (!string.Equals(user.PhoneNumber, input.PhoneNumber, StringComparison.InvariantCultureIgnoreCase))
{
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber).ConfigureAwait(false)).CheckErrors();
}
(await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled)).CheckErrors();
(await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled)).CheckErrors();
(await _userManager.SetTwoFactorEnabledAsync(user, input.TwoFactorEnabled).ConfigureAwait(false)).CheckErrors();
(await _userManager.SetLockoutEnabledAsync(user, input.LockoutEnabled).ConfigureAwait(false)).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).ConfigureAwait(false)).CheckErrors();
}
}
}

@ -18,7 +18,7 @@ namespace Volo.Abp.Identity
public virtual async Task<UserData> FindByIdAsync(Guid id)
{
var userData = await UserLookupServiceProvider.FindByIdAsync(id);
var userData = await UserLookupServiceProvider.FindByIdAsync(id).ConfigureAwait(false);
if (userData == null)
{
return null;
@ -29,7 +29,7 @@ namespace Volo.Abp.Identity
public virtual async Task<UserData> FindByUserNameAsync(string userName)
{
var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName);
var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName).ConfigureAwait(false);
if (userData == null)
{
return null;

@ -21,39 +21,39 @@ namespace Volo.Abp.Identity
{
return ObjectMapper.Map<IdentityUser, ProfileDto>(
await _userManager.GetByIdAsync(CurrentUser.GetId())
);
.ConfigureAwait(false));
}
public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
{
var user = await _userManager.GetByIdAsync(CurrentUser.GetId());
var user = await _userManager.GetByIdAsync(CurrentUser.GetId()).ConfigureAwait(false);
if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled))
if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled).ConfigureAwait(false))
{
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
(await _userManager.SetUserNameAsync(user, input.UserName).ConfigureAwait(false)).CheckErrors();
}
if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled))
if (await SettingProvider.IsTrueAsync(IdentitySettingNames.User.IsEmailUpdateEnabled).ConfigureAwait(false))
{
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();
(await _userManager.SetEmailAsync(user, input.Email).ConfigureAwait(false)).CheckErrors();
}
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber).ConfigureAwait(false)).CheckErrors();
user.Name = input.Name;
user.Surname = input.Surname;
(await _userManager.UpdateAsync(user)).CheckErrors();
(await _userManager.UpdateAsync(user).ConfigureAwait(false)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
return ObjectMapper.Map<IdentityUser, ProfileDto>(user);
}
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()).ConfigureAwait(false);
(await _userManager.ChangePasswordAsync(currentUser, input.CurrentPassword, input.NewPassword).ConfigureAwait(false)).CheckErrors();
}
}
}

@ -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.Password.RequiredLength = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredLength, options.Password.RequiredLength).ConfigureAwait(false);
options.Password.RequiredUniqueChars = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequiredUniqueChars, options.Password.RequiredUniqueChars).ConfigureAwait(false);
options.Password.RequireNonAlphanumeric = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireNonAlphanumeric, options.Password.RequireNonAlphanumeric).ConfigureAwait(false);
options.Password.RequireLowercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireLowercase, options.Password.RequireLowercase).ConfigureAwait(false);
options.Password.RequireUppercase = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireUppercase, options.Password.RequireUppercase).ConfigureAwait(false);
options.Password.RequireDigit = await _settingProvider.GetAsync(IdentitySettingNames.Password.RequireDigit, options.Password.RequireDigit).ConfigureAwait(false);
options.Lockout.AllowedForNewUsers = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.AllowedForNewUsers, options.Lockout.AllowedForNewUsers).ConfigureAwait(false);
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.Lockout.MaxFailedAccessAttempts = await _settingProvider.GetAsync(IdentitySettingNames.Lockout.MaxFailedAccessAttempts, options.Lockout.MaxFailedAccessAttempts).ConfigureAwait(false);
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.SignIn.RequireConfirmedEmail = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedEmail, options.SignIn.RequireConfirmedEmail).ConfigureAwait(false);
options.SignIn.RequireConfirmedPhoneNumber = await _settingProvider.GetAsync(IdentitySettingNames.SignIn.RequireConfirmedPhoneNumber, options.SignIn.RequireConfirmedPhoneNumber).ConfigureAwait(false);
}
}

@ -25,7 +25,7 @@ namespace Volo.Abp.Identity
[UnitOfWork]
public override async Task<ClaimsPrincipal> CreateAsync(IdentityUser user)
{
var principal = await base.CreateAsync(user);
var principal = await base.CreateAsync(user).ConfigureAwait(false);
if (user.TenantId.HasValue)
{

@ -15,17 +15,17 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityClaimType> CreateAsync(IdentityClaimType claimType)
{
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name))
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name).ConfigureAwait(false))
{
throw new AbpException($"Name Exist: {claimType.Name}");
}
return await _identityClaimTypeRepository.InsertAsync(claimType);
return await _identityClaimTypeRepository.InsertAsync(claimType).ConfigureAwait(false);
}
public virtual async Task<IdentityClaimType> UpdateAsync(IdentityClaimType claimType)
{
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id))
if (await _identityClaimTypeRepository.AnyAsync(claimType.Name, claimType.Id).ConfigureAwait(false))
{
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).ConfigureAwait(false);
}
}
}

@ -47,7 +47,7 @@ namespace Volo.Abp.Identity
const string adminUserName = "admin";
var adminUser = await _userRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.NormalizeName(adminUserName)
);
).ConfigureAwait(false);
if (adminUser != null)
{
@ -64,12 +64,12 @@ namespace Volo.Abp.Identity
Name = adminUserName
};
(await _userManager.CreateAsync(adminUser, adminPassword)).CheckErrors();
(await _userManager.CreateAsync(adminUser, adminPassword).ConfigureAwait(false)).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)).ConfigureAwait(false);
if (adminRole == null)
{
adminRole = new IdentityRole(
@ -82,11 +82,11 @@ namespace Volo.Abp.Identity
IsPublic = true
};
(await _roleManager.CreateAsync(adminRole)).CheckErrors();
(await _roleManager.CreateAsync(adminRole).ConfigureAwait(false)).CheckErrors();
result.CreatedAdminRole = true;
}
(await _userManager.AddToRoleAsync(adminUser, adminRoleName)).CheckErrors();
(await _userManager.AddToRoleAsync(adminUser, adminRoleName).ConfigureAwait(false)).CheckErrors();
return result;
}

@ -41,7 +41,7 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityRole> GetByIdAsync(Guid id)
{
var role = await Store.FindByIdAsync(id.ToString(), CancellationToken);
var role = await Store.FindByIdAsync(id.ToString(), CancellationToken).ConfigureAwait(false);
if (role == null)
{
throw new EntityNotFoundException(typeof(IdentityRole), id);
@ -57,7 +57,7 @@ namespace Volo.Abp.Identity
throw new BusinessException(_localizer["Identity.StaticRoleRenamingErrorMessage"]); // TODO: localize & change exception type
}
return await base.SetRoleNameAsync(role,name);
return await base.SetRoleNameAsync(role, name).ConfigureAwait(false);
}
public override async Task<IdentityResult> DeleteAsync(IdentityRole role)
@ -67,7 +67,7 @@ namespace Volo.Abp.Identity
throw new BusinessException(_localizer["Identity.StaticRoleDeletionErrorMessage"]); // TODO: localize & change exception type
}
return await base.DeleteAsync(role);
return await base.DeleteAsync(role).ConfigureAwait(false);
}
}
}

@ -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).ConfigureAwait(false);
return IdentityResult.Success;
}
@ -86,7 +86,7 @@ namespace Volo.Abp.Identity
try
{
await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken);
await _roleRepository.UpdateAsync(role, AutoSaveChanges, cancellationToken).ConfigureAwait(false);
}
catch (AbpDbConcurrencyException ex)
{
@ -111,7 +111,7 @@ namespace Volo.Abp.Identity
try
{
await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken);
await _roleRepository.DeleteAsync(role, AutoSaveChanges, cancellationToken).ConfigureAwait(false);
}
catch (AbpDbConcurrencyException ex)
{
@ -249,7 +249,7 @@ namespace Volo.Abp.Identity
Check.NotNull(role, nameof(role));
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken);
await _roleRepository.EnsureCollectionLoadedAsync(role, r => r.Claims, cancellationToken).ConfigureAwait(false);
return role.Claims.Select(c => c.ToClaim()).ToList();
}
@ -268,7 +268,7 @@ namespace Volo.Abp.Identity
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).ConfigureAwait(false);
role.AddClaim(_guidGenerator, claim);
}
@ -285,7 +285,7 @@ namespace Volo.Abp.Identity
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).ConfigureAwait(false);
role.RemoveClaim(claim);
}

@ -45,7 +45,7 @@ namespace Volo.Abp.Identity
public virtual async Task<IdentityUser> GetByIdAsync(Guid id)
{
var user = await Store.FindByIdAsync(id.ToString(), CancellationToken);
var user = await Store.FindByIdAsync(id.ToString(), CancellationToken).ConfigureAwait(false);
if (user == null)
{
throw new EntityNotFoundException(typeof(IdentityUser), id);
@ -59,15 +59,15 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
Check.NotNull(roleNames, nameof(roleNames));
var currentRoleNames = await GetRolesAsync(user);
var currentRoleNames = await GetRolesAsync(user).ConfigureAwait(false);
var result = await RemoveFromRolesAsync(user, currentRoleNames.Except(roleNames).Distinct());
var result = await RemoveFromRolesAsync(user, currentRoleNames.Except(roleNames).Distinct()).ConfigureAwait(false);
if (!result.Succeeded)
{
return result;
}
result = await AddToRolesAsync(user, roleNames.Except(currentRoleNames).Distinct());
result = await AddToRolesAsync(user, roleNames.Except(currentRoleNames).Distinct()).ConfigureAwait(false);
if (!result.Succeeded)
{
return result;

@ -30,7 +30,7 @@ namespace Volo.Abp.Identity
includeDetails: false,
cancellationToken: cancellationToken
)
)?.ToAbpUserData();
.ConfigureAwait(false))?.ToAbpUserData();
}
public virtual async Task<IUserData> FindByUserNameAsync(
@ -43,7 +43,7 @@ namespace Volo.Abp.Identity
includeDetails: false,
cancellationToken: cancellationToken
)
)?.ToAbpUserData();
.ConfigureAwait(false))?.ToAbpUserData();
}
}
}

@ -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).ConfigureAwait(false);
return IdentityResult.Success;
}
@ -182,7 +182,7 @@ namespace Volo.Abp.Identity
try
{
await _userRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken);
await _userRepository.UpdateAsync(user, AutoSaveChanges, cancellationToken).ConfigureAwait(false);
}
catch (AbpDbConcurrencyException ex)
{
@ -207,7 +207,7 @@ namespace Volo.Abp.Identity
try
{
await _userRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken);
await _userRepository.DeleteAsync(user, AutoSaveChanges, cancellationToken).ConfigureAwait(false);
}
catch (AbpDbConcurrencyException ex)
{
@ -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).ConfigureAwait(false);
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).ConfigureAwait(false);
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).ConfigureAwait(false);
if (role == null)
{
return;
}
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken).ConfigureAwait(false);
user.RemoveRole(role.Id);
}
@ -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).ConfigureAwait(false);
if (role == null)
{
return false;
}
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken);
await _userRepository.EnsureCollectionLoadedAsync(user, u => u.Roles, cancellationToken).ConfigureAwait(false);
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).ConfigureAwait(false);
return user.Claims.Select(c => c.ToClaim()).ToList();
}
@ -430,7 +430,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).ConfigureAwait(false);
user.AddClaims(_guidGenerator, claims);
}
@ -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).ConfigureAwait(false);
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).ConfigureAwait(false);
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).ConfigureAwait(false);
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).ConfigureAwait(false);
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).ConfigureAwait(false);
return user.Logins.Select(l => l.ToUserLoginInfo()).ToList();
}
@ -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).ConfigureAwait(false);
user.SetToken(loginProvider, name, value);
}
@ -1007,7 +1007,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).ConfigureAwait(false);
user.RemoveToken(loginProvider, name);
}
@ -1026,7 +1026,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).ConfigureAwait(false);
return user.FindToken(loginProvider, name)?.Value;
}
@ -1053,7 +1053,7 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken) ?? "";
var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken).ConfigureAwait(false) ?? "";
if (mergedCodes.Length > 0)
{
return mergedCodes.Split(';').Length;
@ -1090,12 +1090,12 @@ namespace Volo.Abp.Identity
Check.NotNull(user, nameof(user));
Check.NotNull(code, nameof(code));
var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken) ?? "";
var mergedCodes = await GetTokenAsync(user, InternalLoginProvider, RecoveryCodeTokenName, cancellationToken).ConfigureAwait(false) ?? "";
var splitCodes = mergedCodes.Split(';');
if (splitCodes.Contains(code))
{
var updatedCodes = new List<string>(splitCodes.Where(s => s != code));
await ReplaceCodesAsync(user, updatedCodes, cancellationToken);
await ReplaceCodesAsync(user, updatedCodes, cancellationToken).ConfigureAwait(false);
return true;
}
return false;

@ -15,7 +15,7 @@ namespace Volo.Abp.Identity
public virtual async Task<string[]> GetRolesAsync(Guid userId)
{
return (await _identityUserRepository.GetRoleNamesAsync(userId)).ToArray();
return (await _identityUserRepository.GetRoleNamesAsync(userId).ConfigureAwait(false)).ToArray();
}
}
}

@ -21,7 +21,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
return await DbSet
.WhereIf(ignoredId != null, ct => ct.Id != ignoredId)
.CountAsync(ct => ct.Name == name) > 0;
.CountAsync(ct => ct.Name == name).ConfigureAwait(false) > 0;
}
public async Task<List<IdentityClaimType>> GetListAsync(string sorting, int maxResultCount, int skipCount, string filter)
@ -34,7 +34,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
)
.OrderBy(sorting ?? "name desc")
.PageBy(skipCount, maxResultCount)
.ToListAsync();
.ToListAsync().ConfigureAwait(false);
return identityClaimTypes;
}

@ -25,7 +25,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
return await DbSet
.IncludeDetails(includeDetails)
.FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken));
.FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<List<IdentityRole>> GetListAsync(
@ -39,7 +39,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
.IncludeDetails(includeDetails)
.OrderBy(sorting ?? nameof(IdentityRole.Name))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public override IQueryable<IdentityRole> WithDetails()

@ -28,7 +28,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken)
);
).ConfigureAwait(false);
}
public virtual async Task<List<string>> GetRoleNamesAsync(
@ -40,7 +40,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
where userRole.UserId == id
select role.Name;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
return await query.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<IdentityUser> FindByLoginAsync(
@ -52,7 +52,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return await DbSet
.IncludeDetails(includeDetails)
.Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey))
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<IdentityUser> FindByNormalizedEmailAsync(
@ -62,7 +62,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
return await DbSet
.IncludeDetails(includeDetails)
.FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken));
.FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<List<IdentityUser>> GetListByClaimAsync(
@ -73,7 +73,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return await DbSet
.IncludeDetails(includeDetails)
.Where(u => u.Claims.Any(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value))
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync(
@ -83,7 +83,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
{
var role = await DbContext.Roles
.Where(x => x.NormalizedName == normalizedRoleName)
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
if (role == null)
{
@ -93,7 +93,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
return await DbSet
.IncludeDetails(includeDetails)
.Where(u => u.Roles.Any(r => r.RoleId == role.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<List<IdentityUser>> GetListAsync(
@ -114,7 +114,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
)
.OrderBy(sorting ?? nameof(IdentityUser.UserName))
.PageBy(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<List<IdentityRole>> GetRolesAsync(
@ -127,7 +127,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
where userRole.UserId == id
select role;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
return await query.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public virtual async Task<long> GetCountAsync(
@ -140,7 +140,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
u.UserName.Contains(filter) ||
u.Email.Contains(filter)
)
.LongCountAsync(GetCancellationToken(cancellationToken));
.LongCountAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public override IQueryable<IdentityUser> WithDetails()

@ -17,7 +17,7 @@ namespace Volo.Abp.Identity
public async Task<string[]> GetRolesAsync(Guid userId)
{
var output = await _userAppService.GetRolesAsync(userId);
var output = await _userAppService.GetRolesAsync(userId).ConfigureAwait(false);
return output.Items.Select(r => r.Name).ToArray();
}
}

@ -22,13 +22,13 @@ namespace Volo.Abp.Identity.MongoDB
{
return await GetMongoQueryable()
.Where(ct => ct.Name == name)
.AnyAsync();
.AnyAsync().ConfigureAwait(false);
}
else
{
return await GetMongoQueryable()
.Where(ct => ct.Id != ignoredId && ct.Name == name)
.AnyAsync();
.AnyAsync().ConfigureAwait(false);
}
}
@ -43,7 +43,7 @@ namespace Volo.Abp.Identity.MongoDB
.OrderBy(sorting ?? nameof(IdentityClaimType.Name))
.As<IMongoQueryable<IdentityClaimType>>()
.PageBy<IdentityClaimType, IMongoQueryable<IdentityClaimType>>(skipCount, maxResultCount)
.ToListAsync();
.ToListAsync().ConfigureAwait(false);
}
}
}

@ -27,7 +27,7 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken));
return await GetMongoQueryable().FirstOrDefaultAsync(r => r.NormalizedName == normalizedRoleName, GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<List<IdentityRole>> GetListAsync(
@ -41,7 +41,7 @@ namespace Volo.Abp.Identity.MongoDB
.OrderBy(sorting ?? nameof(IdentityRole.Name))
.As<IMongoQueryable<IdentityRole>>()
.PageBy<IdentityRole, IMongoQueryable<IdentityRole>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
}
}

@ -32,16 +32,16 @@ namespace Volo.Abp.Identity.MongoDB
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken)
);
).ConfigureAwait(false);
}
public async Task<List<string>> GetRoleNamesAsync(
Guid id,
CancellationToken cancellationToken = default)
{
var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken));
var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken)).ConfigureAwait(false);
var roleIds = user.Roles.Select(r => r.RoleId).ToArray();
return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(GetCancellationToken(cancellationToken));
return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).Select(r => r.Name).ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<IdentityUser> FindByLoginAsync(
@ -51,8 +51,8 @@ namespace Volo.Abp.Identity.MongoDB
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable()
.Where(u=> u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey))
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
.Where(u => u.Logins.Any(login => login.LoginProvider == loginProvider && login.ProviderKey == providerKey))
.FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<IdentityUser> FindByNormalizedEmailAsync(
@ -60,7 +60,7 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return await GetMongoQueryable().FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken));
return await GetMongoQueryable().FirstOrDefaultAsync(u => u.NormalizedEmail == normalizedEmail, GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<List<IdentityUser>> GetListByClaimAsync(
@ -70,7 +70,7 @@ namespace Volo.Abp.Identity.MongoDB
{
return await GetMongoQueryable()
.Where(u => u.Claims.Any(c => c.ClaimType == claim.Type && c.ClaimValue == claim.Value))
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<List<IdentityUser>> GetListByNormalizedRoleNameAsync(
@ -78,7 +78,7 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var role = await DbContext.Roles.AsQueryable().Where(x => x.NormalizedName == normalizedRoleName).FirstOrDefaultAsync(GetCancellationToken(cancellationToken));
var role = await DbContext.Roles.AsQueryable().Where(x => x.NormalizedName == normalizedRoleName).FirstOrDefaultAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
if (role == null)
{
@ -87,7 +87,7 @@ namespace Volo.Abp.Identity.MongoDB
return await GetMongoQueryable()
.Where(u => u.Roles.Any(r => r.RoleId == role.Id))
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<List<IdentityUser>> GetListAsync(
@ -108,7 +108,7 @@ namespace Volo.Abp.Identity.MongoDB
.OrderBy(sorting ?? nameof(IdentityUser.UserName))
.As<IMongoQueryable<IdentityUser>>()
.PageBy<IdentityUser, IMongoQueryable<IdentityUser>>(skipCount, maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<List<IdentityRole>> GetRolesAsync(
@ -116,9 +116,9 @@ namespace Volo.Abp.Identity.MongoDB
bool includeDetails = false,
CancellationToken cancellationToken = default)
{
var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken));
var user = await GetAsync(id, cancellationToken: GetCancellationToken(cancellationToken)).ConfigureAwait(false);
var roleIds = user.Roles.Select(r => r.RoleId).ToArray();
return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).ToListAsync(GetCancellationToken(cancellationToken));
return await DbContext.Roles.AsQueryable().Where(r => roleIds.Contains(r.Id)).ToListAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
public async Task<long> GetCountAsync(
@ -132,7 +132,7 @@ namespace Volo.Abp.Identity.MongoDB
u.UserName.Contains(filter) ||
u.Email.Contains(filter)
)
.LongCountAsync(GetCancellationToken(cancellationToken));
.LongCountAsync(GetCancellationToken(cancellationToken)).ConfigureAwait(false);
}
}
}

@ -18,8 +18,8 @@ namespace Volo.Abp.Identity.Web.Navigation
var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();
var hasRolePermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Roles.Default);
var hasUserPermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Users.Default);
var hasRolePermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Roles.Default).ConfigureAwait(false);
var hasUserPermission = await authorizationService.IsGrantedAsync(IdentityPermissions.Users.Default).ConfigureAwait(false);
if (hasRolePermission || hasUserPermission)
{

@ -21,7 +21,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
ValidateModel();
var input = ObjectMapper.Map<RoleInfoModel, IdentityRoleCreateDto>(Role);
await _identityRoleAppService.CreateAsync(input);
await _identityRoleAppService.CreateAsync(input).ConfigureAwait(false);
return NoContent();
}

@ -22,7 +22,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
{
Role = ObjectMapper.Map<IdentityRoleDto, RoleInfoModel>(
await _identityRoleAppService.GetAsync(id)
);
.ConfigureAwait(false));
}
public async Task<IActionResult> OnPostAsync()
@ -30,7 +30,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Roles
ValidateModel();
var input = ObjectMapper.Map<RoleInfoModel, IdentityRoleUpdateDto>(Role);
await _identityRoleAppService.UpdateAsync(Role.Id, input);
await _identityRoleAppService.UpdateAsync(Role.Id, input).ConfigureAwait(false);
return NoContent();
}

@ -28,7 +28,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
{
UserInfo = new UserInfoViewModel();
var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto());
var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false);
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList.Items);
@ -45,7 +45,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
var input = ObjectMapper.Map<UserInfoViewModel, IdentityUserCreateDto>(UserInfo);
input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray();
await _identityUserAppService.CreateAsync(input);
await _identityUserAppService.CreateAsync(input).ConfigureAwait(false);
return NoContent();
}

@ -28,13 +28,13 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
public async Task OnGetAsync(Guid id)
{
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id));
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id).ConfigureAwait(false));
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(
(await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto())).Items
(await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false)).Items
);
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList();
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id).ConfigureAwait(false)).Items.Select(r => r.Name).ToList();
foreach (var role in Roles)
{
if (userRoleNames.Contains(role.Name))
@ -50,7 +50,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users
var input = ObjectMapper.Map<UserInfoViewModel, IdentityUserUpdateDto>(UserInfo);
input.RoleNames = Roles.Where(r => r.IsAssigned).Select(r => r.Name).ToArray();
await _identityUserAppService.UpdateAsync(UserInfo.Id, input);
await _identityUserAppService.UpdateAsync(UserInfo.Id, input).ConfigureAwait(false);
return NoContent();
}

@ -39,11 +39,11 @@ 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).ConfigureAwait(false);
foreach (var roleName in roleNames)
{
var permissionGrant = await PermissionGrantRepository.FindAsync(name, Name, roleName);
var permissionGrant = await PermissionGrantRepository.FindAsync(name, Name, roleName).ConfigureAwait(false);
if (permissionGrant != null)
{
return new PermissionValueProviderGrantInfo(true, roleName);

@ -23,11 +23,11 @@ namespace Volo.Abp.Identity
{
//Arrange
var moderator = await GetRoleAsync("moderator");
var moderator = await GetRoleAsync("moderator").ConfigureAwait(false);
//Act
var result = await _roleAppService.GetAsync(moderator.Id);
var result = await _roleAppService.GetAsync(moderator.Id).ConfigureAwait(false);
//Assert
@ -39,7 +39,7 @@ namespace Volo.Abp.Identity
{
//Act
var result = await _roleAppService.GetListAsync(new PagedAndSortedResultRequestDto());
var result = await _roleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false);
//Assert
@ -58,14 +58,14 @@ namespace Volo.Abp.Identity
//Act
var result = await _roleAppService.CreateAsync(input);
var result = await _roleAppService.CreateAsync(input).ConfigureAwait(false);
//Assert
result.Id.ShouldNotBe(Guid.Empty);
result.Name.ShouldBe(input.Name);
var role = await _roleRepository.GetAsync(result.Id);
var role = await _roleRepository.GetAsync(result.Id).ConfigureAwait(false);
role.Name.ShouldBe(input.Name);
}
@ -74,7 +74,7 @@ namespace Volo.Abp.Identity
{
//Arrange
var moderator = await GetRoleAsync("moderator");
var moderator = await GetRoleAsync("moderator").ConfigureAwait(false);
var input = new IdentityRoleUpdateDto
{
@ -86,14 +86,14 @@ namespace Volo.Abp.Identity
//Act
var result = await _roleAppService.UpdateAsync(moderator.Id, input);
var result = await _roleAppService.UpdateAsync(moderator.Id, input).ConfigureAwait(false);
//Assert
result.Id.ShouldBe(moderator.Id);
result.Name.ShouldBe(input.Name);
var updatedRole = await _roleRepository.GetAsync(moderator.Id);
var updatedRole = await _roleRepository.GetAsync(moderator.Id).ConfigureAwait(false);
updatedRole.Name.ShouldBe(input.Name);
}
@ -102,15 +102,15 @@ namespace Volo.Abp.Identity
{
//Arrange
var moderator = await GetRoleAsync("moderator");
var moderator = await GetRoleAsync("moderator").ConfigureAwait(false);
//Act
await _roleAppService.DeleteAsync(moderator.Id);
await _roleAppService.DeleteAsync(moderator.Id).ConfigureAwait(false);
//Assert
(await FindRoleAsync("moderator")).ShouldBeNull();
(await FindRoleAsync("moderator").ConfigureAwait(false)).ShouldBeNull();
}
private async Task<IdentityRole> GetRoleAsync(string roleName)

@ -28,7 +28,7 @@ namespace Volo.Abp.Identity
//Act
var result = await _userAppService.GetAsync(johnNash.Id);
var result = await _userAppService.GetAsync(johnNash.Id).ConfigureAwait(false);
//Assert
@ -44,7 +44,7 @@ namespace Volo.Abp.Identity
{
//Act
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput());
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()).ConfigureAwait(false);
//Assert
@ -69,7 +69,7 @@ namespace Volo.Abp.Identity
//Act
var result = await _userAppService.CreateAsync(input);
var result = await _userAppService.CreateAsync(input).ConfigureAwait(false);
//Assert
@ -79,7 +79,7 @@ namespace Volo.Abp.Identity
result.LockoutEnabled.ShouldBe(input.LockoutEnabled);
result.PhoneNumber.ShouldBe(input.PhoneNumber);
var user = await _userRepository.GetAsync(result.Id);
var user = await _userRepository.GetAsync(result.Id).ConfigureAwait(false);
user.Id.ShouldBe(result.Id);
user.UserName.ShouldBe(input.UserName);
user.Email.ShouldBe(input.Email);
@ -110,7 +110,7 @@ namespace Volo.Abp.Identity
//Act
var result = await _userAppService.UpdateAsync(johnNash.Id, input);
var result = await _userAppService.UpdateAsync(johnNash.Id, input).ConfigureAwait(false);
//Assert
@ -120,7 +120,7 @@ namespace Volo.Abp.Identity
result.LockoutEnabled.ShouldBe(input.LockoutEnabled);
result.PhoneNumber.ShouldBe(input.PhoneNumber);
var user = await _userRepository.GetAsync(result.Id);
var user = await _userRepository.GetAsync(result.Id).ConfigureAwait(false);
user.Id.ShouldBe(result.Id);
user.UserName.ShouldBe(input.UserName);
user.Email.ShouldBe(input.Email);
@ -134,7 +134,7 @@ namespace Volo.Abp.Identity
public async Task UpdateAsync_Concurrency_Exception()
{
//Get user
var johnNash = await _userAppService.GetAsync(_testData.UserJohnId);
var johnNash = await _userAppService.GetAsync(_testData.UserJohnId).ConfigureAwait(false);
//Act
@ -151,13 +151,13 @@ namespace Volo.Abp.Identity
ConcurrencyStamp = johnNash.ConcurrencyStamp
};
await _userAppService.UpdateAsync(johnNash.Id, input);
await _userAppService.UpdateAsync(johnNash.Id, input).ConfigureAwait(false);
//Second update with same input will throw exception because the entity has been modified
(await Assert.ThrowsAsync<AbpIdentityResultException>(async () =>
{
await _userAppService.UpdateAsync(johnNash.Id, input);
})).Message.ShouldContain("Optimistic concurrency failure");
await _userAppService.UpdateAsync(johnNash.Id, input).ConfigureAwait(false);
}).ConfigureAwait(false)).Message.ShouldContain("Optimistic concurrency failure");
}
[Fact]
@ -169,7 +169,7 @@ namespace Volo.Abp.Identity
//Act
await _userAppService.DeleteAsync(johnNash.Id);
await _userAppService.DeleteAsync(johnNash.Id).ConfigureAwait(false);
//Assert
@ -185,7 +185,7 @@ namespace Volo.Abp.Identity
//Act
var result = await _userAppService.GetRolesAsync(johnNash.Id);
var result = await _userAppService.GetRolesAsync(johnNash.Id).ConfigureAwait(false);
//Assert
@ -209,11 +209,11 @@ namespace Volo.Abp.Identity
{
RoleNames = new[] { "admin", "moderator" }
}
);
).ConfigureAwait(false);
//Assert
var roleNames = await _userRepository.GetRoleNamesAsync(johnNash.Id);
var roleNames = await _userRepository.GetRoleNamesAsync(johnNash.Id).ConfigureAwait(false);
roleNames.Count.ShouldBe(2);
roleNames.ShouldContain("admin");
roleNames.ShouldContain("moderator");

@ -24,32 +24,32 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByIdAsync()
{
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserLookupAppService.FindByIdAsync(user.Id)).UserName.ShouldBe(user.UserName);
(await _identityUserLookupAppService.FindByIdAsync(user.Id).ConfigureAwait(false)).UserName.ShouldBe(user.UserName);
}
[Fact]
public async Task FindById_NotExist_Should_Return_Null()
{
var user = await _identityUserLookupAppService.FindByIdAsync(Guid.NewGuid());
var user = await _identityUserLookupAppService.FindByIdAsync(Guid.NewGuid()).ConfigureAwait(false);
user.ShouldBeNull();
}
[Fact]
public async Task FindByUserNameAsync()
{
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserLookupAppService.FindByUserNameAsync(user.UserName)).UserName.ShouldBe(user.UserName);
(await _identityUserLookupAppService.FindByUserNameAsync(user.UserName).ConfigureAwait(false)).UserName.ShouldBe(user.UserName);
}
[Fact]
public async Task FindByUserName_NotExist_Should_Return_Null()
{
var user = await _identityUserLookupAppService.FindByUserNameAsync(Guid.NewGuid().ToString());
var user = await _identityUserLookupAppService.FindByUserNameAsync(Guid.NewGuid().ToString()).ConfigureAwait(false);
user.ShouldBeNull();
}
}

@ -34,7 +34,7 @@ namespace Volo.Abp.Identity
_currentUser.IsAuthenticated.Returns(true);
//Act
var result = await _profileAppService.GetAsync();
var result = await _profileAppService.GetAsync().ConfigureAwait(false);
//Assert
var johnNash = GetUser("john.nash");
@ -62,7 +62,7 @@ namespace Volo.Abp.Identity
};
//Act
var result = await _profileAppService.UpdateAsync(input);
var result = await _profileAppService.UpdateAsync(input).ConfigureAwait(false);
//Assert
result.UserName.ShouldBe(input.UserName);

@ -40,11 +40,11 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
await _userManager.SetEmailAsync(user, "john.nash_UPDATED@abp.io");
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
await _userManager.SetEmailAsync(user, "john.nash_UPDATED@abp.io").ConfigureAwait(false);
_testCounter.GetValue("EntityUpdatedEto<UserEto>").ShouldBe(0);
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
_testCounter.GetValue("EntityUpdatedEto<UserEto>").ShouldBe(1);

@ -25,7 +25,7 @@ namespace Volo.Abp.Identity
{
var claimType = await _claimTypeManager.CreateAsync(new IdentityClaimType(Guid.NewGuid(), "Phone", false,
false, null,
null, null, IdentityClaimValueType.String));
null, null, IdentityClaimValueType.String)).ConfigureAwait(false);
claimType.ShouldNotBeNull();
claimType.Name.ShouldBe("Phone");
@ -36,17 +36,17 @@ namespace Volo.Abp.Identity
{
await Assert.ThrowsAnyAsync<AbpException>(async () => await _claimTypeManager.CreateAsync(
new IdentityClaimType(
Guid.NewGuid(), "Age")));
Guid.NewGuid(), "Age")).ConfigureAwait(false)).ConfigureAwait(false);
}
[Fact]
public async Task UpdateAsync()
{
var ageClaim = await _identityClaimTypeRepository.FindAsync(_testData.AgeClaimId);
var ageClaim = await _identityClaimTypeRepository.FindAsync(_testData.AgeClaimId).ConfigureAwait(false);
ageClaim.ShouldNotBeNull();
ageClaim.Description = "this is age";
var updatedAgeClaimType = await _claimTypeManager.UpdateAsync(ageClaim);
var updatedAgeClaimType = await _claimTypeManager.UpdateAsync(ageClaim).ConfigureAwait(false);
updatedAgeClaimType.ShouldNotBeNull();
updatedAgeClaimType.Description.ShouldBe("this is age");
}
@ -57,7 +57,7 @@ namespace Volo.Abp.Identity
{
await Assert.ThrowsAnyAsync<AbpException>(async () => await _claimTypeManager.UpdateAsync(
new IdentityClaimType(
Guid.NewGuid(), "Age")));
Guid.NewGuid(), "Age")).ConfigureAwait(false)).ConfigureAwait(false);
}
@ -65,9 +65,9 @@ namespace Volo.Abp.Identity
public async Task Static_IdentityClaimType_Cant_Not_Update()
{
var phoneClaim = new IdentityClaimType(Guid.NewGuid(), "Phone", true, true);
await _identityClaimTypeRepository.InsertAsync(phoneClaim);
await _identityClaimTypeRepository.InsertAsync(phoneClaim).ConfigureAwait(false);
await Assert.ThrowsAnyAsync<AbpException>(async () => await _claimTypeManager.UpdateAsync(phoneClaim));
await Assert.ThrowsAnyAsync<AbpException>(async () => await _claimTypeManager.UpdateAsync(phoneClaim).ConfigureAwait(false)).ConfigureAwait(false);
}
}
}

@ -28,7 +28,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetByIdAsync()
{
var role = await _identityRoleManager.FindByIdAsync(_testData.RoleModeratorId.ToString());
var role = await _identityRoleManager.FindByIdAsync(_testData.RoleModeratorId.ToString()).ConfigureAwait(false);
role.ShouldNotBeNull();
role.Name.ShouldBe("moderator");
@ -37,10 +37,10 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
(await _identityRoleManager.SetRoleNameAsync(role, "teacher")).Succeeded.ShouldBeTrue();
(await _identityRoleManager.SetRoleNameAsync(role, "teacher").ConfigureAwait(false)).Succeeded.ShouldBeTrue();
role.Name.ShouldBe("teacher");
}
@ -48,12 +48,12 @@ namespace Volo.Abp.Identity
[Fact]
public async Task DeleteAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
await _identityRoleManager.DeleteAsync(role);
await _identityRoleManager.DeleteAsync(role).ConfigureAwait(false);
(await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"))).ShouldBeNull();
(await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false)).ShouldBeNull();
}
}

@ -32,9 +32,9 @@ namespace Volo.Abp.Identity
{
var roleId = Guid.NewGuid();
var role = new IdentityRole(roleId, "teacher");
(await _identityRoleStore.CreateAsync(role)).Succeeded.ShouldBeTrue();
(await _identityRoleStore.CreateAsync(role).ConfigureAwait(false)).Succeeded.ShouldBeTrue();
var teacher = await _identityRoleStore.FindByIdAsync(roleId.ToString());
var teacher = await _identityRoleStore.FindByIdAsync(roleId.ToString()).ConfigureAwait(false);
teacher.ShouldNotBeNull();
teacher.Name.ShouldBe("teacher");
@ -43,11 +43,11 @@ namespace Volo.Abp.Identity
[Fact]
public async Task UpdateAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
role.IsDefault = true;
await _identityRoleStore.UpdateAsync(role);
await _identityRoleStore.UpdateAsync(role).ConfigureAwait(false);
role.IsDefault.ShouldBeTrue();
}
@ -56,40 +56,40 @@ namespace Volo.Abp.Identity
[Fact]
public async Task DeleteAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
await _identityRoleStore.DeleteAsync(role);
await _identityRoleStore.DeleteAsync(role).ConfigureAwait(false);
(await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString())).ShouldBeNull();
(await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString()).ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
public async Task GetRoleIdAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
(await _identityRoleStore.GetRoleIdAsync(role)).ShouldBe(_testData.RoleModeratorId.ToString());
(await _identityRoleStore.GetRoleIdAsync(role).ConfigureAwait(false)).ShouldBe(_testData.RoleModeratorId.ToString());
}
[Fact]
public async Task GetRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
(await _identityRoleStore.GetRoleNameAsync(role)).ShouldBe(role.Name);
(await _identityRoleStore.GetRoleNameAsync(role).ConfigureAwait(false)).ShouldBe(role.Name);
}
[Fact]
public async Task SetRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
await _identityRoleStore.SetRoleNameAsync(role, "teacher");
await _identityRoleStore.SetRoleNameAsync(role, "teacher").ConfigureAwait(false);
role.Name.ShouldBe("teacher");
}
@ -97,7 +97,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByIdAsync()
{
var role = await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString());
var role = await _identityRoleStore.FindByIdAsync(_testData.RoleModeratorId.ToString()).ConfigureAwait(false);
role.ShouldNotBeNull();
role.Name.ShouldBe("moderator");
@ -106,7 +106,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByNameAsync()
{
var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleStore.FindByNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
role.Name.ShouldBe("moderator");
@ -115,19 +115,19 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetNormalizedRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
(await _identityRoleStore.GetNormalizedRoleNameAsync(role)).ShouldBe(role.NormalizedName);
(await _identityRoleStore.GetNormalizedRoleNameAsync(role).ConfigureAwait(false)).ShouldBe(role.NormalizedName);
}
[Fact]
public async Task SetNormalizedRoleNameAsync()
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
await _identityRoleStore.SetNormalizedRoleNameAsync(role, _lookupNormalizer.NormalizeName("teacher"));
await _identityRoleStore.SetNormalizedRoleNameAsync(role, _lookupNormalizer.NormalizeName("teacher")).ConfigureAwait(false);
role.NormalizedName.ShouldBe(_lookupNormalizer.NormalizeName("teacher"));
}
@ -137,15 +137,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
var claims = await _identityRoleStore.GetClaimsAsync(role);
var claims = await _identityRoleStore.GetClaimsAsync(role).ConfigureAwait(false);
claims.ShouldNotBeEmpty();
claims.ShouldContain(x => x.Type == "test-claim" && x.Value == "test-value");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -156,7 +156,7 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
role.Claims.Add(new IdentityRoleClaim(Guid.NewGuid(), role.Id, "my-claim", "my-value", role.TenantId));
@ -164,7 +164,7 @@ namespace Volo.Abp.Identity
//role.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -173,7 +173,7 @@ namespace Volo.Abp.Identity
throw;
}
var role2 = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role2 = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role2.ShouldNotBeNull();
role2.Claims.ShouldContain(x => x.ClaimType == "my-claim" && x.ClaimValue == "my-value");
}
@ -183,14 +183,14 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));
var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.ShouldNotBeNull();
await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value"));
await _identityRoleStore.RemoveClaimAsync(role, new Claim("test-claim", "test-value")).ConfigureAwait(false);
role.Claims.ShouldNotContain(x => x.ClaimType == "test-claim" && x.ClaimValue == "test-value");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
}

@ -31,7 +31,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetByIdAsync()
{
var user = await _identityUserManager.GetByIdAsync(_testData.UserJohnId);
var user = await _identityUserManager.GetByIdAsync(_testData.UserJohnId).ConfigureAwait(false);
user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash");
@ -43,18 +43,18 @@ namespace Volo.Abp.Identity
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.NormalizeName("david"));
_lookupNormalizer.NormalizeName("david")).ConfigureAwait(false);
user.ShouldNotBeNull();
var identityResult = await _identityUserManager.SetRolesAsync(user, new List<string>()
{
"moderator",
});
}).ConfigureAwait(false);
identityResult.Succeeded.ShouldBeTrue();
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId);
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -64,23 +64,23 @@ namespace Volo.Abp.Identity
using (var uow = _unitOfWorkManager.Begin())
{
var roleSupporter =
await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("supporter"));
await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("supporter")).ConfigureAwait(false);
roleSupporter.ShouldNotBeNull();
var user = await _identityUserRepository.FindByNormalizedUserNameAsync(
_lookupNormalizer.NormalizeName("john.nash"));
_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var identityResult = await _identityUserManager.SetRolesAsync(user, new List<string>()
{
"admin",
});
}).ConfigureAwait(false);
identityResult.Succeeded.ShouldBeTrue();
user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId);
user.Roles.ShouldNotContain(x => x.RoleId == roleSupporter.Id);
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
}

@ -29,29 +29,29 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetUserIdAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetUserIdAsync(user)).ShouldBe(user.Id.ToString());
(await _identityUserStore.GetUserIdAsync(user).ConfigureAwait(false)).ShouldBe(user.Id.ToString());
}
[Fact]
public async Task GetUserNameAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetUserNameAsync(user)).ShouldBe(user.UserName);
(await _identityUserStore.GetUserNameAsync(user).ConfigureAwait(false)).ShouldBe(user.UserName);
}
[Fact]
public async Task SetUserNameAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetUserNameAsync(user, "bob.lee");
await _identityUserStore.SetUserNameAsync(user, "bob.lee").ConfigureAwait(false);
user.UserName.ShouldBe("bob.lee");
//user.NormalizedUserName.ShouldBe(_lookupNormalizer.Normalize("bob.lee"));
}
@ -60,19 +60,19 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetNormalizedUserNameAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetNormalizedUserNameAsync(user)).ShouldBe(user.NormalizedUserName);
(await _identityUserStore.GetNormalizedUserNameAsync(user).ConfigureAwait(false)).ShouldBe(user.NormalizedUserName);
}
[Fact]
public async Task SetNormalizedUserNameAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee"));
await _identityUserStore.SetNormalizedUserNameAsync(user, _lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false);
user.NormalizedUserName.ShouldBe(_lookupNormalizer.NormalizeName("bob.lee"));
}
@ -83,9 +83,9 @@ namespace Volo.Abp.Identity
var userId = Guid.NewGuid();
var user = new IdentityUser(userId, "bob.lee", "bob.lee@abp.io");
await _identityUserStore.CreateAsync(user);
await _identityUserStore.CreateAsync(user).ConfigureAwait(false);
var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee"));
var bobLee = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("bob.lee")).ConfigureAwait(false);
bobLee.ShouldNotBeNull();
bobLee.UserName.ShouldBe("bob.lee");
bobLee.Email.ShouldBe("bob.lee@abp.io");
@ -94,26 +94,26 @@ namespace Volo.Abp.Identity
[Fact]
public async Task UpdateAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Name = "lee";
(await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue();
(await _identityUserStore.UpdateAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).Name
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).Name
.ShouldBe("lee");
}
[Fact]
public async Task Update_Concurrency()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.UpdateAsync(user)).Succeeded.ShouldBeTrue();
(await _identityUserStore.UpdateAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue();
user.ConcurrencyStamp = Guid.NewGuid().ToString();
var identityResult = await _identityUserStore.UpdateAsync(user);
var identityResult = await _identityUserStore.UpdateAsync(user).ConfigureAwait(false);
identityResult.Succeeded.ShouldBeFalse();
identityResult.Errors.ShouldContain(x =>
@ -126,19 +126,19 @@ namespace Volo.Abp.Identity
[Fact]
public async Task DeleteAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.DeleteAsync(user)).Succeeded.ShouldBeTrue();
(await _identityUserStore.DeleteAsync(user).ConfigureAwait(false)).Succeeded.ShouldBeTrue();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"))).ShouldBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
public async Task FindByIdAsync()
{
var user = await _identityUserStore.FindByIdAsync(_testData.UserJohnId.ToString());
var user = await _identityUserStore.FindByIdAsync(_testData.UserJohnId.ToString()).ConfigureAwait(false);
user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash");
@ -148,7 +148,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByNameAsync()
{
var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _identityUserStore.FindByNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash");
@ -158,11 +158,11 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetPasswordHashAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.PasswordHash.ShouldBeNull();
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd");
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false);
user.PasswordHash.ShouldBe("P@ssw0rd");
}
@ -170,23 +170,23 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetPasswordHashAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd");
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false);
(await _identityUserStore.GetPasswordHashAsync(user)).ShouldBe("P@ssw0rd");
(await _identityUserStore.GetPasswordHashAsync(user).ConfigureAwait(false)).ShouldBe("P@ssw0rd");
}
[Fact]
public async Task HasPasswordAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.HasPasswordAsync(user)).ShouldBeFalse();
(await _identityUserStore.HasPasswordAsync(user).ConfigureAwait(false)).ShouldBeFalse();
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd");
(await _identityUserStore.HasPasswordAsync(user)).ShouldBeTrue();
await _identityUserStore.SetPasswordHashAsync(user, "P@ssw0rd").ConfigureAwait(false);
(await _identityUserStore.HasPasswordAsync(user).ConfigureAwait(false)).ShouldBeTrue();
}
[Fact]
@ -194,15 +194,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Roles.ShouldBeEmpty();
await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"));
await _identityUserStore.AddToRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId);
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -211,15 +211,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Roles.ShouldContain(x => x.RoleId == _testData.RoleModeratorId);
await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"));
await _identityUserStore.RemoveFromRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
user.Roles.ShouldNotContain(x => x.RoleId == _testData.RoleModeratorId);
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -227,10 +227,10 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetRolesAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var roleNames = await _identityUserStore.GetRolesAsync(user);
var roleNames = await _identityUserStore.GetRolesAsync(user).ConfigureAwait(false);
roleNames.ShouldNotBeEmpty();
roleNames.ShouldContain(x => x == "moderator");
roleNames.ShouldContain(x => x == "supporter");
@ -241,13 +241,13 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator"))).ShouldBeTrue();
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist"))).ShouldBeFalse();
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false)).ShouldBeTrue();
(await _identityUserStore.IsInRoleAsync(user, _lookupNormalizer.NormalizeName("moderatorNotExist")).ConfigureAwait(false)).ShouldBeFalse();
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -256,14 +256,14 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var claims = await _identityUserStore.GetClaimsAsync(user);
var claims = await _identityUserStore.GetClaimsAsync(user).ConfigureAwait(false);
claims.ShouldNotBeEmpty();
claims.ShouldContain(x => x.Type == "TestClaimType" && x.Value == "42");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -272,18 +272,18 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Claims.ShouldNotContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue");
await _identityUserStore.AddClaimsAsync(user, new List<Claim>()
{
new Claim("MyClaimType", "MyClaimValue")
});
}).ConfigureAwait(false);
user.Claims.ShouldContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -292,15 +292,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.ReplaceClaimAsync(user, new Claim("TestClaimType", "42"), new Claim("MyClaimType", "MyClaimValue"));
await _identityUserStore.ReplaceClaimAsync(user, new Claim("TestClaimType", "42"), new Claim("MyClaimType", "MyClaimValue")).ConfigureAwait(false);
user.Claims.ShouldNotContain(x => x.ClaimType == "TestClaimType" && x.ClaimValue == "42");
user.Claims.ShouldContain(x => x.ClaimType == "MyClaimType" && x.ClaimValue == "MyClaimValue");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -309,17 +309,17 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.RemoveClaimsAsync(user, new List<Claim>()
{
new Claim("TestClaimType", "42")
});
}).ConfigureAwait(false);
user.Claims.ShouldNotContain(x => x.ClaimType == "TestClaimType" && x.ClaimValue == "42");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -328,15 +328,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Logins.ShouldNotContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john");
await _identityUserStore.AddLoginAsync(user, new UserLoginInfo("facebook", "john", "John Nash"));
await _identityUserStore.AddLoginAsync(user, new UserLoginInfo("facebook", "john", "John Nash")).ConfigureAwait(false);
user.Logins.ShouldContain(x => x.LoginProvider == "facebook" && x.ProviderKey == "john");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -345,15 +345,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john");
await _identityUserStore.RemoveLoginAsync(user, "github", "john");
await _identityUserStore.RemoveLoginAsync(user, "github", "john").ConfigureAwait(false);
user.Logins.ShouldNotContain(x => x.LoginProvider == "github" && x.ProviderKey == "john");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -363,16 +363,16 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var logins = await _identityUserStore.GetLoginsAsync(user);
var logins = await _identityUserStore.GetLoginsAsync(user).ConfigureAwait(false);
logins.ShouldNotBeNull();
logins.ShouldContain(x => x.LoginProvider == "github" && x.ProviderKey == "john");
logins.ShouldContain(x => x.LoginProvider == "twitter" && x.ProviderKey == "johnx");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -380,7 +380,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByLoginAsync()
{
var user = await _identityUserStore.FindByLoginAsync("github", "john");
var user = await _identityUserStore.FindByLoginAsync("github", "john").ConfigureAwait(false);
user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash");
}
@ -389,21 +389,21 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetEmailConfirmedAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetEmailConfirmedAsync(user)).ShouldBe(user.EmailConfirmed);
(await _identityUserStore.GetEmailConfirmedAsync(user).ConfigureAwait(false)).ShouldBe(user.EmailConfirmed);
}
[Fact]
public async Task SetEmailConfirmedAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var emailConfirmed = user.EmailConfirmed;
await _identityUserStore.SetEmailConfirmedAsync(user, !emailConfirmed);
await _identityUserStore.SetEmailConfirmedAsync(user, !emailConfirmed).ConfigureAwait(false);
user.EmailConfirmed.ShouldBe(!emailConfirmed);
}
@ -411,10 +411,10 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetEmailAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io");
await _identityUserStore.SetEmailAsync(user, "john.nash.kobe@abp.io").ConfigureAwait(false);
user.Email.ShouldBe("john.nash.kobe@abp.io");
//user.NormalizedEmail.ShouldBe(_lookupNormalizer.Normalize("john.nash.kobe@abp.io"));
@ -423,28 +423,28 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetEmailAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetEmailAsync(user)).ShouldBe(user.Email);
(await _identityUserStore.GetEmailAsync(user).ConfigureAwait(false)).ShouldBe(user.Email);
}
[Fact]
public async Task GetNormalizedEmailAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetNormalizedEmailAsync(user)).ShouldBe(user.NormalizedEmail);
(await _identityUserStore.GetNormalizedEmailAsync(user).ConfigureAwait(false)).ShouldBe(user.NormalizedEmail);
}
[Fact]
public async Task SetNormalizedEmailAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io"));
await _identityUserStore.SetNormalizedEmailAsync(user, _lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io")).ConfigureAwait(false);
user.NormalizedEmail.ShouldBe(_lookupNormalizer.NormalizeEmail("john.nash.kobe@abp.io"));
}
@ -452,7 +452,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByEmailAsync()
{
var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io"));
var user = await _identityUserStore.FindByEmailAsync(_lookupNormalizer.NormalizeEmail("john.nash@abp.io")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.Email.ShouldBe("john.nash@abp.io");
@ -461,19 +461,19 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetLockoutEndDateAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetLockoutEndDateAsync(user)).ShouldBe(user.LockoutEnd);
(await _identityUserStore.GetLockoutEndDateAsync(user).ConfigureAwait(false)).ShouldBe(user.LockoutEnd);
}
[Fact]
public async Task SetLockoutEndDateAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019"));
await _identityUserStore.SetLockoutEndDateAsync(user, DateTimeOffset.Parse("01/01/2019")).ConfigureAwait(false);
user.LockoutEnd.ShouldBe(DateTimeOffset.Parse("01/01/2019"));
}
@ -482,11 +482,11 @@ namespace Volo.Abp.Identity
[Fact]
public async Task IncrementAccessFailedCountAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var count = user.AccessFailedCount;
await _identityUserStore.IncrementAccessFailedCountAsync(user);
await _identityUserStore.IncrementAccessFailedCountAsync(user).ConfigureAwait(false);
user.AccessFailedCount.ShouldBe(count + 1);
}
@ -494,10 +494,10 @@ namespace Volo.Abp.Identity
[Fact]
public async Task ResetAccessFailedCountAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.ResetAccessFailedCountAsync(user);
await _identityUserStore.ResetAccessFailedCountAsync(user).ConfigureAwait(false);
user.AccessFailedCount.ShouldBe(0);
}
@ -505,29 +505,29 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetAccessFailedCountAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetAccessFailedCountAsync(user)).ShouldBe(user.AccessFailedCount);
(await _identityUserStore.GetAccessFailedCountAsync(user).ConfigureAwait(false)).ShouldBe(user.AccessFailedCount);
}
[Fact]
public async Task GetLockoutEnabledAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetLockoutEnabledAsync(user)).ShouldBe(user.LockoutEnabled);
(await _identityUserStore.GetLockoutEnabledAsync(user).ConfigureAwait(false)).ShouldBe(user.LockoutEnabled);
}
[Fact]
public async Task SetLockoutEnabledAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var lockoutEnabled = user.LockoutEnabled;
await _identityUserStore.SetLockoutEnabledAsync(user, !lockoutEnabled);
await _identityUserStore.SetLockoutEnabledAsync(user, !lockoutEnabled).ConfigureAwait(false);
user.LockoutEnabled.ShouldBe(!lockoutEnabled);
}
@ -536,10 +536,10 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetPhoneNumberAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetPhoneNumberAsync(user, "13800138000");
await _identityUserStore.SetPhoneNumberAsync(user, "13800138000").ConfigureAwait(false);
user.PhoneNumber.ShouldBe("13800138000");
}
@ -548,30 +548,30 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetPhoneNumberAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetPhoneNumberAsync(user)).ShouldBe(user.PhoneNumber);
(await _identityUserStore.GetPhoneNumberAsync(user).ConfigureAwait(false)).ShouldBe(user.PhoneNumber);
}
[Fact]
public async Task GetPhoneNumberConfirmedAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetPhoneNumberConfirmedAsync(user)).ShouldBe(user.PhoneNumberConfirmed);
(await _identityUserStore.GetPhoneNumberConfirmedAsync(user).ConfigureAwait(false)).ShouldBe(user.PhoneNumberConfirmed);
}
[Fact]
public async Task SetPhoneNumberConfirmedAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var phoneNumberConfirmed = user.PhoneNumberConfirmed;
await _identityUserStore.SetPhoneNumberConfirmedAsync(user, !phoneNumberConfirmed);
await _identityUserStore.SetPhoneNumberConfirmedAsync(user, !phoneNumberConfirmed).ConfigureAwait(false);
user.PhoneNumberConfirmed.ShouldBe(!phoneNumberConfirmed);
}
@ -580,11 +580,11 @@ namespace Volo.Abp.Identity
[Fact]
public async Task SetSecurityStampAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var securityStamp = Guid.NewGuid().ToString();
await _identityUserStore.SetSecurityStampAsync(user, securityStamp);
await _identityUserStore.SetSecurityStampAsync(user, securityStamp).ConfigureAwait(false);
user.SecurityStamp.ShouldBe(securityStamp);
}
@ -592,21 +592,21 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetSecurityStampAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetSecurityStampAsync(user)).ShouldBe(user.SecurityStamp);
(await _identityUserStore.GetSecurityStampAsync(user).ConfigureAwait(false)).ShouldBe(user.SecurityStamp);
}
[Fact]
public async Task SetTwoFactorEnabledAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
var twoFactorEnabled = user.TwoFactorEnabled;
await _identityUserStore.SetTwoFactorEnabledAsync(user, !twoFactorEnabled);
await _identityUserStore.SetTwoFactorEnabledAsync(user, !twoFactorEnabled).ConfigureAwait(false);
user.TwoFactorEnabled.ShouldBe(!twoFactorEnabled);
}
@ -615,16 +615,16 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetTwoFactorEnabledAsync()
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetTwoFactorEnabledAsync(user)).ShouldBe(user.TwoFactorEnabled);
(await _identityUserStore.GetTwoFactorEnabledAsync(user).ConfigureAwait(false)).ShouldBe(user.TwoFactorEnabled);
}
[Fact]
public async Task GetUsersForClaimAsync()
{
var user = await _identityUserStore.GetUsersForClaimAsync(new Claim("TestClaimType", "42"));
var user = await _identityUserStore.GetUsersForClaimAsync(new Claim("TestClaimType", "42")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.ShouldNotBeEmpty();
user.ShouldContain(x => x.UserName == "john.nash");
@ -633,7 +633,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetUsersInRoleAsync()
{
var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator"));
var user = await _identityUserStore.GetUsersInRoleAsync(_lookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
user.ShouldNotBeNull();
user.ShouldContain(x => x.UserName == "john.nash");
}
@ -643,15 +643,15 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123");
await _identityUserStore.SetTokenAsync(user, "test-provider", "test-name", "123123").ConfigureAwait(false);
user.Tokens.ShouldNotBeEmpty();
user.Tokens.ShouldContain(x => x.LoginProvider == "test-provider" && x.Name == "test-name" && x.Value == "123123");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -660,14 +660,14 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name");
await _identityUserStore.RemoveTokenAsync(user, "test-provider", "test-name").ConfigureAwait(false);
user.Tokens.ShouldNotContain(x => x.LoginProvider == "test-provider" && x.Name == "test-name" && x.Value == "123123");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -676,12 +676,12 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
(await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name")).ShouldBe("test-value");
(await _identityUserStore.GetTokenAsync(user, "test-provider", "test-name").ConfigureAwait(false)).ShouldBe("test-value");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -690,14 +690,14 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey");
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey").ConfigureAwait(false);
user.Tokens.ShouldContain(x => x.LoginProvider == "[AspNetUserStore]" && x.Name == "AuthenticatorKey" && x.Value == "testKey");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -706,13 +706,13 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey");
await _identityUserStore.SetAuthenticatorKeyAsync(user, "testKey").ConfigureAwait(false);
(await _identityUserStore.GetAuthenticatorKeyAsync(user)).ShouldBe("testKey");
(await _identityUserStore.GetAuthenticatorKeyAsync(user).ConfigureAwait(false)).ShouldBe("testKey");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -722,13 +722,13 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2");
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2").ConfigureAwait(false);
(await _identityUserStore.CountCodesAsync(user)).ShouldBe(2);
(await _identityUserStore.CountCodesAsync(user).ConfigureAwait(false)).ShouldBe(2);
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -737,18 +737,18 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.ReplaceCodesAsync(user, new List<string>()
{
"testKey",
"testKey2"
});
}).ConfigureAwait(false);
user.Tokens.ShouldContain(x => x.LoginProvider == "[AspNetUserStore]" && x.Name == "RecoveryCodes" && x.Value == "testKey;testKey2");
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -757,13 +757,13 @@ namespace Volo.Abp.Identity
{
using (var uow = _unitOfWorkManager.Begin())
{
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash"));
var user = await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
user.ShouldNotBeNull();
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2");
await _identityUserStore.SetTokenAsync(user, "[AspNetUserStore]", "RecoveryCodes", "testKey;testKey2").ConfigureAwait(false);
(await _identityUserStore.RedeemCodeAsync(user, "testKey")).ShouldBeTrue();
(await _identityUserStore.RedeemCodeAsync(user, "testKey").ConfigureAwait(false)).ShouldBeTrue();
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
}

@ -24,19 +24,19 @@ namespace Volo.Abp.Identity
public async Task Roles_Should_Have_Configured_Permissions()
{
//admin
var grantInfos = await _permissionManager.GetAllForRoleAsync("admin");
var grantInfos = await _permissionManager.GetAllForRoleAsync("admin").ConfigureAwait(false);
RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission1);
RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission2);
RoleShouldHavePermission(grantInfos, "admin", TestPermissionNames.MyPermission2_ChildPermission1);
//moderator
grantInfos = await _permissionManager.GetAllForRoleAsync("moderator");
grantInfos = await _permissionManager.GetAllForRoleAsync("moderator").ConfigureAwait(false);
RoleShouldHavePermission(grantInfos, "moderator", TestPermissionNames.MyPermission1);
RoleShouldHavePermission(grantInfos, "moderator", TestPermissionNames.MyPermission2);
ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1);
//supporter
grantInfos = await _permissionManager.GetAllForRoleAsync("supporter");
grantInfos = await _permissionManager.GetAllForRoleAsync("supporter").ConfigureAwait(false);
RoleShouldHavePermission(grantInfos, "supporter", TestPermissionNames.MyPermission1);
ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2);
ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1);
@ -45,21 +45,21 @@ namespace Volo.Abp.Identity
[Fact]
public async Task Should_Grant_Permission_To_Role()
{
(await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2)).IsGranted.ShouldBeFalse();
(await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter")).ShouldBeFalse();
(await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2).ConfigureAwait(false)).IsGranted.ShouldBeFalse();
(await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter").ConfigureAwait(false)).ShouldBeFalse();
await _permissionManager.SetForRoleAsync("supporter", TestPermissionNames.MyPermission2, true);
await _permissionManager.SetForRoleAsync("supporter", TestPermissionNames.MyPermission2, true).ConfigureAwait(false);
(await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2)).IsGranted.ShouldBeTrue();
(await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter")).ShouldBeTrue();
(await _permissionManager.GetForRoleAsync("supporter", TestPermissionNames.MyPermission2).ConfigureAwait(false)).IsGranted.ShouldBeTrue();
(await _permissionStore.IsGrantedAsync(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "supporter").ConfigureAwait(false)).ShouldBeTrue();
}
[Fact]
public async Task Should_Revoke_Permission_From_Role()
{
(await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1)).IsGranted.ShouldBeTrue();
await _permissionManager.SetForRoleAsync("moderator", TestPermissionNames.MyPermission1, false);
(await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1)).IsGranted.ShouldBeFalse();
(await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1).ConfigureAwait(false)).IsGranted.ShouldBeTrue();
await _permissionManager.SetForRoleAsync("moderator", TestPermissionNames.MyPermission1, false).ConfigureAwait(false);
(await _permissionManager.GetForRoleAsync("moderator", TestPermissionNames.MyPermission1).ConfigureAwait(false)).IsGranted.ShouldBeFalse();
}
[Fact]
@ -67,21 +67,21 @@ namespace Volo.Abp.Identity
{
//administrator
var user = GetUser("administrator");
var grantInfos = await _permissionManager.GetAllForUserAsync(user.Id);
var grantInfos = await _permissionManager.GetAllForUserAsync(user.Id).ConfigureAwait(false);
UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission1, "admin");
UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission2, "admin");
UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission2_ChildPermission1, "admin");
//john.nash
user = GetUser("john.nash");
grantInfos = await _permissionManager.GetAllForUserAsync(user.Id);
grantInfos = await _permissionManager.GetAllForUserAsync(user.Id).ConfigureAwait(false);
UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission1, "moderator", "supporter");
UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission2, "moderator");
ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1);
//john.nash
user = GetUser("david");
grantInfos = await _permissionManager.GetAllForUserAsync(user.Id);
grantInfos = await _permissionManager.GetAllForUserAsync(user.Id).ConfigureAwait(false);
UserShouldHavePermission(grantInfos, user.Id, TestPermissionNames.MyPermission1);
ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2);
ShouldNotHavePermission(grantInfos, TestPermissionNames.MyPermission2_ChildPermission1);

@ -29,26 +29,26 @@ namespace Volo.Abp.Identity
public async Task Build()
{
await AddRolePermissions();
await AddUserPermissions();
await AddRolePermissions().ConfigureAwait(false);
await AddUserPermissions().ConfigureAwait(false);
}
private async Task AddRolePermissions()
{
await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "admin");
await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "admin");
await AddPermission(TestPermissionNames.MyPermission2_ChildPermission1, RolePermissionValueProvider.ProviderName, "admin");
await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "admin").ConfigureAwait(false);
await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "admin").ConfigureAwait(false);
await AddPermission(TestPermissionNames.MyPermission2_ChildPermission1, RolePermissionValueProvider.ProviderName, "admin").ConfigureAwait(false);
await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "moderator");
await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "moderator");
await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "moderator").ConfigureAwait(false);
await AddPermission(TestPermissionNames.MyPermission2, RolePermissionValueProvider.ProviderName, "moderator").ConfigureAwait(false);
await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "supporter");
await AddPermission(TestPermissionNames.MyPermission1, RolePermissionValueProvider.ProviderName, "supporter").ConfigureAwait(false);
}
private async Task AddUserPermissions()
{
var david = AsyncHelper.RunSync(() => _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("david")));
await AddPermission(TestPermissionNames.MyPermission1, UserPermissionValueProvider.ProviderName, david.Id.ToString());
await AddPermission(TestPermissionNames.MyPermission1, UserPermissionValueProvider.ProviderName, david.Id.ToString()).ConfigureAwait(false);
}
private async Task AddPermission(string permissionName, string providerName, string providerKey)
@ -60,7 +60,7 @@ namespace Volo.Abp.Identity
providerName,
providerKey
)
);
).ConfigureAwait(false);
}
}
}

@ -21,7 +21,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetRolesAsync()
{
var roleNames = await _userRoleFinder.GetRolesAsync(_testData.UserJohnId);
var roleNames = await _userRoleFinder.GetRolesAsync(_testData.UserJohnId).ConfigureAwait(false);
roleNames.ShouldNotBeEmpty();
roleNames.ShouldContain(x => x == "moderator");
roleNames.ShouldContain(x => x == "supporter");

@ -32,10 +32,10 @@ namespace Volo.Abp.Identity
var dataSeeder = scope.ServiceProvider.GetRequiredService<IDataSeeder>();
AsyncHelper.RunSync(async () =>
{
await dataSeeder.SeedAsync();
await dataSeeder.SeedAsync().ConfigureAwait(false);
await scope.ServiceProvider
.GetRequiredService<AbpIdentityTestDataBuilder>()
.Build();
.Build().ConfigureAwait(false);
});
}
}

@ -37,21 +37,21 @@ namespace Volo.Abp.Identity
public async Task Build()
{
await AddRoles();
await AddUsers();
await AddClaimTypes();
await AddRoles().ConfigureAwait(false);
await AddUsers().ConfigureAwait(false);
await AddClaimTypes().ConfigureAwait(false);
}
private async Task AddRoles()
{
_adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"));
_adminRole = await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false);
_moderator = new IdentityRole(_testData.RoleModeratorId, "moderator");
_moderator.AddClaim(_guidGenerator, new Claim("test-claim", "test-value"));
await _roleRepository.InsertAsync(_moderator);
await _roleRepository.InsertAsync(_moderator).ConfigureAwait(false);
_supporterRole = new IdentityRole(_guidGenerator.Create(), "supporter");
await _roleRepository.InsertAsync(_supporterRole);
await _roleRepository.InsertAsync(_supporterRole).ConfigureAwait(false);
}
private async Task AddUsers()
@ -59,7 +59,7 @@ namespace Volo.Abp.Identity
var adminUser = new IdentityUser(_guidGenerator.Create(), "administrator", "admin@abp.io");
adminUser.AddRole(_adminRole.Id);
adminUser.AddClaim(_guidGenerator, new Claim("TestClaimType", "42"));
await _userRepository.InsertAsync(adminUser);
await _userRepository.InsertAsync(adminUser).ConfigureAwait(false);
var john = new IdentityUser(_testData.UserJohnId, "john.nash", "john.nash@abp.io");
john.AddRole(_moderator.Id);
@ -68,23 +68,23 @@ namespace Volo.Abp.Identity
john.AddLogin(new UserLoginInfo("twitter", "johnx", "John Nash"));
john.AddClaim(_guidGenerator, new Claim("TestClaimType", "42"));
john.SetToken("test-provider", "test-name", "test-value");
await _userRepository.InsertAsync(john);
await _userRepository.InsertAsync(john).ConfigureAwait(false);
var david = new IdentityUser(_testData.UserDavidId, "david", "david@abp.io");
await _userRepository.InsertAsync(david);
await _userRepository.InsertAsync(david).ConfigureAwait(false);
var neo = new IdentityUser(_testData.UserNeoId, "neo", "neo@abp.io");
neo.AddRole(_supporterRole.Id);
neo.AddClaim(_guidGenerator, new Claim("TestClaimType", "43"));
await _userRepository.InsertAsync(neo);
await _userRepository.InsertAsync(neo).ConfigureAwait(false);
}
private async Task AddClaimTypes()
{
var ageClaim = new IdentityClaimType(_testData.AgeClaimId, "Age", false, false, null, null, null,IdentityClaimValueType.Int);
await _identityClaimTypeRepository.InsertAsync(ageClaim);
await _identityClaimTypeRepository.InsertAsync(ageClaim).ConfigureAwait(false);
var educationClaim = new IdentityClaimType(_testData.EducationClaimId, "Education", true, false, null, null, null);
await _identityClaimTypeRepository.InsertAsync(educationClaim);
await _identityClaimTypeRepository.InsertAsync(educationClaim).ConfigureAwait(false);
}
}
}

@ -28,11 +28,11 @@ namespace Volo.Abp.Identity
{
var claim = (await ClaimTypeRepository.GetListAsync()).FirstOrDefault();
var result1 = await ClaimTypeRepository.AnyAsync(claim.Name);
var result1 = await ClaimTypeRepository.AnyAsync(claim.Name).ConfigureAwait(false);
result1.ShouldBe(true);
var result2 = await ClaimTypeRepository.AnyAsync(Guid.NewGuid().ToString());
var result2 = await ClaimTypeRepository.AnyAsync(Guid.NewGuid().ToString()).ConfigureAwait(false);
result2.ShouldBe(false);
}

@ -25,11 +25,11 @@ namespace Volo.Abp.Identity
[Fact]
public async Task Should_Create_Admin_User_And_Role()
{
await _identityDataSeeder.SeedAsync("admin@abp.io", "1q2w3E*");
await _identityDataSeeder.SeedAsync("admin@abp.io", "1q2w3E*").ConfigureAwait(false);
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin"))).Name.ShouldBe("admin");
(await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).ShouldNotBeNull();
(await _userRepository.FindByNormalizedUserNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).Name.ShouldBe("admin");
(await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).ShouldNotBeNull();
}
}
}

@ -23,14 +23,14 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByNormalizedNameAsync()
{
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("admin"))).ShouldNotBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("undefined-role"))).ShouldBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("admin")).ConfigureAwait(false)).ShouldNotBeNull();
(await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("undefined-role")).ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
public async Task GetListAsync()
{
var roles = await RoleRepository.GetListAsync();
var roles = await RoleRepository.GetListAsync().ConfigureAwait(false);
roles.ShouldContain(r => r.Name == "admin");
roles.ShouldContain(r => r.Name == "moderator");
roles.ShouldContain(r => r.Name == "supporter");
@ -39,13 +39,13 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetCountAsync()
{
(await RoleRepository.GetCountAsync()).ShouldBeGreaterThan(0);
(await RoleRepository.GetCountAsync().ConfigureAwait(false)).ShouldBeGreaterThan(0);
}
[Fact]
public async Task Should_Eager_Load_Role_Collections()
{
var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"));
var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator")).ConfigureAwait(false);
role.Claims.ShouldNotBeNull();
role.Claims.Any().ShouldBeTrue();
}

@ -25,23 +25,23 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByNormalizedUserNameAsync()
{
(await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"))).ShouldNotBeNull();
(await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("undefined-user"))).ShouldBeNull();
(await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false)).ShouldNotBeNull();
(await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("undefined-user")).ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
public async Task FindByNormalizedEmailAsync()
{
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("john.nash@abp.io"))).ShouldNotBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("david@abp.io"))).ShouldNotBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("undefined-user@abp.io"))).ShouldBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("john.nash@abp.io")).ConfigureAwait(false)).ShouldNotBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("david@abp.io")).ConfigureAwait(false)).ShouldNotBeNull();
(await UserRepository.FindByNormalizedEmailAsync(LookupNormalizer.NormalizeEmail("undefined-user@abp.io")).ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
public async Task GetRoleNamesAsync()
{
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"));
var roles = await UserRepository.GetRoleNamesAsync(john.Id);
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
var roles = await UserRepository.GetRoleNamesAsync(john.Id).ConfigureAwait(false);
roles.Count.ShouldBe(2);
roles.ShouldContain("moderator");
roles.ShouldContain("supporter");
@ -50,37 +50,37 @@ namespace Volo.Abp.Identity
[Fact]
public async Task FindByLoginAsync()
{
var user = await UserRepository.FindByLoginAsync("github", "john");
var user = await UserRepository.FindByLoginAsync("github", "john").ConfigureAwait(false);
user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash");
user = await UserRepository.FindByLoginAsync("twitter", "johnx");
user = await UserRepository.FindByLoginAsync("twitter", "johnx").ConfigureAwait(false);
user.ShouldNotBeNull();
user.UserName.ShouldBe("john.nash");
(await UserRepository.FindByLoginAsync("github", "undefinedid")).ShouldBeNull();
(await UserRepository.FindByLoginAsync("github", "undefinedid").ConfigureAwait(false)).ShouldBeNull();
}
[Fact]
public async Task GetListByClaimAsync()
{
var users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "42"));
var users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "42")).ConfigureAwait(false);
users.Count.ShouldBe(2);
users.ShouldContain(u => u.UserName == "administrator");
users.ShouldContain(u => u.UserName == "john.nash");
users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "43"));
users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "43")).ConfigureAwait(false);
users.Count.ShouldBe(1);
users.ShouldContain(u => u.UserName == "neo");
users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "undefined"));
users = await UserRepository.GetListByClaimAsync(new Claim("TestClaimType", "undefined")).ConfigureAwait(false);
users.Count.ShouldBe(0);
}
[Fact]
public async Task GetListByNormalizedRoleNameAsync()
{
var users = await UserRepository.GetListByNormalizedRoleNameAsync(LookupNormalizer.NormalizeName("supporter"));
var users = await UserRepository.GetListByNormalizedRoleNameAsync(LookupNormalizer.NormalizeName("supporter")).ConfigureAwait(false);
users.Count.ShouldBe(2);
users.ShouldContain(u => u.UserName == "john.nash");
users.ShouldContain(u => u.UserName == "neo");
@ -89,7 +89,7 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetListAsync()
{
var users = await UserRepository.GetListAsync("UserName DESC", 5, 0, "n");
var users = await UserRepository.GetListAsync("UserName DESC", 5, 0, "n").ConfigureAwait(false);
users.Count.ShouldBeGreaterThan(1);
users.Count.ShouldBeLessThanOrEqualTo(5);
@ -107,15 +107,15 @@ namespace Volo.Abp.Identity
).ShouldBeGreaterThan(0);
}
users = await UserRepository.GetListAsync(null, 999, 0, "undefined-username");
users = await UserRepository.GetListAsync(null, 999, 0, "undefined-username").ConfigureAwait(false);
users.Count.ShouldBe(0);
}
[Fact]
public async Task GetRolesAsync()
{
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"));
var roles = await UserRepository.GetRolesAsync(john.Id);
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
var roles = await UserRepository.GetRolesAsync(john.Id).ConfigureAwait(false);
roles.Count.ShouldBe(2);
roles.ShouldContain(r => r.Name == "moderator");
roles.ShouldContain(r => r.Name == "supporter");
@ -124,14 +124,14 @@ namespace Volo.Abp.Identity
[Fact]
public async Task GetCountAsync()
{
(await UserRepository.GetCountAsync("n")).ShouldBeGreaterThan(1);
(await UserRepository.GetCountAsync("undefined-username")).ShouldBe(0);
(await UserRepository.GetCountAsync("n").ConfigureAwait(false)).ShouldBeGreaterThan(1);
(await UserRepository.GetCountAsync("undefined-username").ConfigureAwait(false)).ShouldBe(0);
}
[Fact]
public async Task Should_Eager_Load_User_Collections()
{
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"));
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash")).ConfigureAwait(false);
john.Roles.ShouldNotBeNull();
john.Roles.Any().ShouldBeTrue();

@ -28,11 +28,11 @@ namespace Volo.Abp.Identity
{
using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin())
{
var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"), includeDetails: false);
var role = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName("moderator"), includeDetails: false).ConfigureAwait(false);
role.Claims.ShouldNotBeNull();
role.Claims.Any().ShouldBeTrue();
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
@ -41,7 +41,7 @@ namespace Volo.Abp.Identity
{
using (var uow = GetRequiredService<IUnitOfWorkManager>().Begin())
{
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"), includeDetails: false);
var john = await UserRepository.FindByNormalizedUserNameAsync(LookupNormalizer.NormalizeName("john.nash"), includeDetails: false).ConfigureAwait(false);
john.Roles.ShouldNotBeNull();
john.Roles.Any().ShouldBeTrue();
@ -55,7 +55,7 @@ namespace Volo.Abp.Identity
john.Tokens.ShouldNotBeNull();
john.Tokens.Any().ShouldBeTrue();
await uow.CompleteAsync();
await uow.CompleteAsync().ConfigureAwait(false);
}
}
}

Loading…
Cancel
Save