1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

[PM-11409] prevent managed user from leaving managing organization (#4995)

* prevent managed user from leaving managing organization

* fix org check to be specific to single org

* simplify logic
This commit is contained in:
Brandon Treston
2024-11-07 14:10:00 -05:00
committed by GitHub
parent 4adcecb80a
commit 15bc5060c6
2 changed files with 40 additions and 2 deletions

View File

@ -252,6 +252,12 @@ public class OrganizationsController : Controller
throw new BadRequestException("Your organization's Single Sign-On settings prevent you from leaving.");
}
if (_featureService.IsEnabled(FeatureFlagKeys.AccountDeprovisioning)
&& (await _userService.GetOrganizationsManagingUserAsync(user.Id)).Any(x => x.Id == id))
{
throw new BadRequestException("Managed user account cannot leave managing organization. Contact your organization administrator for additional details.");
}
await _removeOrganizationUserCommand.RemoveUserAsync(id, user.Id);
}