mirror of
https://github.com/bitwarden/server.git
synced 2025-04-04 20:50:21 -05:00
Rename GetOrganizationsManagingUserAsync
to GetOrganizationsClaimingUserAsync
.
This renaming clarifies the function's purpose, aligning its name with the concept of "claiming" rather than "managing" user associations.
This commit is contained in:
parent
766f9b6f0f
commit
6b26333ab8
@ -140,7 +140,7 @@ public class OrganizationsController : Controller
|
||||
var organizations = await _organizationUserRepository.GetManyDetailsByUserAsync(userId,
|
||||
OrganizationUserStatusType.Confirmed);
|
||||
|
||||
var organizationManagingActiveUser = await _userService.GetOrganizationsManagingUserAsync(userId);
|
||||
var organizationManagingActiveUser = await _userService.GetOrganizationsClaimingUserAsync(userId);
|
||||
var organizationIdsManagingActiveUser = organizationManagingActiveUser.Select(o => o.Id);
|
||||
|
||||
var responses = organizations.Select(o => new ProfileOrganizationResponseModel(o, organizationIdsManagingActiveUser));
|
||||
@ -277,7 +277,7 @@ public class OrganizationsController : Controller
|
||||
}
|
||||
|
||||
if (_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning)
|
||||
&& (await _userService.GetOrganizationsManagingUserAsync(user.Id)).Any(x => x.Id == id))
|
||||
&& (await _userService.GetOrganizationsClaimingUserAsync(user.Id)).Any(x => x.Id == id))
|
||||
{
|
||||
throw new BadRequestException("Managed user account cannot leave managing organization. Contact your organization administrator for additional details.");
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ public class AccountsController : Controller
|
||||
|
||||
private async Task<IEnumerable<Guid>> GetOrganizationIdsManagingUserAsync(Guid userId)
|
||||
{
|
||||
var organizationManagingUser = await _userService.GetOrganizationsManagingUserAsync(userId);
|
||||
var organizationManagingUser = await _userService.GetOrganizationsClaimingUserAsync(userId);
|
||||
return organizationManagingUser.Select(o => o.Id);
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ public class AccountsController(
|
||||
|
||||
private async Task<IEnumerable<Guid>> GetOrganizationIdsManagingUserAsync(Guid userId)
|
||||
{
|
||||
var organizationManagingUser = await userService.GetOrganizationsManagingUserAsync(userId);
|
||||
var organizationManagingUser = await userService.GetOrganizationsClaimingUserAsync(userId);
|
||||
return organizationManagingUser.Select(o => o.Id);
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ public class OrganizationsController(
|
||||
organizationId,
|
||||
OrganizationUserStatusType.Confirmed);
|
||||
|
||||
var organizationIdsManagingActiveUser = (await userService.GetOrganizationsManagingUserAsync(userId))
|
||||
var organizationIdsManagingActiveUser = (await userService.GetOrganizationsClaimingUserAsync(userId))
|
||||
.Select(o => o.Id);
|
||||
|
||||
return new ProfileOrganizationResponseModel(organizationUserDetails, organizationIdsManagingActiveUser);
|
||||
|
@ -104,7 +104,7 @@ public class SyncController : Controller
|
||||
|
||||
var userTwoFactorEnabled = await _userService.TwoFactorIsEnabledAsync(user);
|
||||
var userHasPremiumFromOrganization = await _userService.HasPremiumFromOrganization(user);
|
||||
var organizationManagingActiveUser = await _userService.GetOrganizationsManagingUserAsync(user.Id);
|
||||
var organizationManagingActiveUser = await _userService.GetOrganizationsClaimingUserAsync(user.Id);
|
||||
var organizationIdsManagingActiveUser = organizationManagingActiveUser.Select(o => o.Id);
|
||||
|
||||
var organizationAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync();
|
||||
|
@ -153,5 +153,5 @@ public interface IUserService
|
||||
/// An empty collection if the Account Deprovisioning feature flag is disabled.
|
||||
/// </returns>
|
||||
/// <inheritdoc cref="IsManagedByAnyOrganizationAsync(Guid)"/>
|
||||
Task<IEnumerable<Organization>> GetOrganizationsManagingUserAsync(Guid userId);
|
||||
Task<IEnumerable<Organization>> GetOrganizationsClaimingUserAsync(Guid userId);
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ public class UserService : UserManager<User>, IUserService, IDisposable
|
||||
|
||||
public async Task<IdentityResult> ValidateClaimedUserDomainAsync(User user, string newEmail)
|
||||
{
|
||||
var managingOrganizations = await GetOrganizationsManagingUserAsync(user.Id);
|
||||
var managingOrganizations = await GetOrganizationsClaimingUserAsync(user.Id);
|
||||
|
||||
if (!managingOrganizations.Any())
|
||||
{
|
||||
@ -1368,11 +1368,11 @@ public class UserService : UserManager<User>, IUserService, IDisposable
|
||||
|
||||
public async Task<bool> IsManagedByAnyOrganizationAsync(Guid userId)
|
||||
{
|
||||
var managingOrganizations = await GetOrganizationsManagingUserAsync(userId);
|
||||
var managingOrganizations = await GetOrganizationsClaimingUserAsync(userId);
|
||||
return managingOrganizations.Any();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Organization>> GetOrganizationsManagingUserAsync(Guid userId)
|
||||
public async Task<IEnumerable<Organization>> GetOrganizationsClaimingUserAsync(Guid userId)
|
||||
{
|
||||
if (!_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning))
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ public class OrganizationsControllerTests : IDisposable
|
||||
_ssoConfigRepository.GetByOrganizationIdAsync(orgId).Returns(ssoConfig);
|
||||
_userService.GetUserByPrincipalAsync(Arg.Any<ClaimsPrincipal>()).Returns(user);
|
||||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true);
|
||||
_userService.GetOrganizationsManagingUserAsync(user.Id).Returns(new List<Organization> { null });
|
||||
_userService.GetOrganizationsClaimingUserAsync(user.Id).Returns(new List<Organization> { null });
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(() => _sut.Leave(orgId));
|
||||
|
||||
Assert.Contains("Your organization's Single Sign-On settings prevent you from leaving.",
|
||||
@ -168,7 +168,7 @@ public class OrganizationsControllerTests : IDisposable
|
||||
_ssoConfigRepository.GetByOrganizationIdAsync(orgId).Returns(ssoConfig);
|
||||
_userService.GetUserByPrincipalAsync(Arg.Any<ClaimsPrincipal>()).Returns(user);
|
||||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true);
|
||||
_userService.GetOrganizationsManagingUserAsync(user.Id).Returns(new List<Organization> { { foundOrg } });
|
||||
_userService.GetOrganizationsClaimingUserAsync(user.Id).Returns(new List<Organization> { { foundOrg } });
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(() => _sut.Leave(orgId));
|
||||
|
||||
Assert.Contains("Managed user account cannot leave managing organization. Contact your organization administrator for additional details.",
|
||||
@ -203,7 +203,7 @@ public class OrganizationsControllerTests : IDisposable
|
||||
_ssoConfigRepository.GetByOrganizationIdAsync(orgId).Returns(ssoConfig);
|
||||
_userService.GetUserByPrincipalAsync(Arg.Any<ClaimsPrincipal>()).Returns(user);
|
||||
_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning).Returns(true);
|
||||
_userService.GetOrganizationsManagingUserAsync(user.Id).Returns(new List<Organization>());
|
||||
_userService.GetOrganizationsClaimingUserAsync(user.Id).Returns(new List<Organization>());
|
||||
|
||||
await _sut.Leave(orgId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user