mirror of
https://github.com/bitwarden/server.git
synced 2025-05-28 23:04:50 -05:00
implement the seat decrease error message
This commit is contained in:
parent
b3f7265129
commit
f62a3e2735
@ -342,11 +342,15 @@ public class OrganizationService : IOrganizationService
|
|||||||
|
|
||||||
if (!organization.Seats.HasValue || organization.Seats.Value > newSeatTotal)
|
if (!organization.Seats.HasValue || organization.Seats.Value > newSeatTotal)
|
||||||
{
|
{
|
||||||
var occupiedSeats = await _organizationUserRepository.GetOccupiedSeatCountByOrganizationIdAsync(organization.Id);
|
var totalConsumedSeats = await _organizationUserRepository.GetOccupiedSeatCountByOrganizationIdAsync(organization.Id);
|
||||||
if (occupiedSeats > newSeatTotal)
|
var organizationUsers = await _organizationUserRepository.GetManyByOrganizationAsync(organization.Id, null);
|
||||||
|
var organizationUserOccupiedSeats = organizationUsers.Where(user => user.Status >= 0).Count();
|
||||||
|
var sponsoredFamiliesOccupiedSeats = totalConsumedSeats - organizationUserOccupiedSeats;
|
||||||
|
|
||||||
|
if (totalConsumedSeats > newSeatTotal)
|
||||||
{
|
{
|
||||||
throw new BadRequestException($"Your organization currently has {occupiedSeats} seats filled. " +
|
throw new BadRequestException($"Your organization has {organizationUserOccupiedSeats} members and {sponsoredFamiliesOccupiedSeats} sponsored families. " +
|
||||||
$"Your new plan only has ({newSeatTotal}) seats. Remove some users.");
|
$"To decrease the seat count below {totalConsumedSeats}, you must remove members or sponsorships.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user