1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-08 06:28:14 -05:00

Throw error if not enough seats available for a sync (#1241)

* BadRequest if a sync cannot be completed due to seat count

* Comment the reason for the suppressed exception
This commit is contained in:
Matt Gibson 2021-03-25 08:42:04 -05:00 committed by GitHub
parent c09ae5f906
commit 584d3e771c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1515,8 +1515,11 @@ namespace Bit.Core.Services
enoughSeatsAvailable = seatsAvailable >= usersToAdd.Count; enoughSeatsAvailable = seatsAvailable >= usersToAdd.Count;
} }
if (enoughSeatsAvailable) if (!enoughSeatsAvailable)
{ {
throw new BadRequestException($"Organization does not have enough seats available. Need {usersToAdd.Count} but {seatsAvailable} available.");
}
foreach (var user in newUsers) foreach (var user in newUsers)
{ {
if (!usersToAdd.Contains(user.ExternalId) || string.IsNullOrWhiteSpace(user.Email)) if (!usersToAdd.Contains(user.ExternalId) || string.IsNullOrWhiteSpace(user.Email))
@ -1539,11 +1542,11 @@ namespace Bit.Core.Services
} }
catch (BadRequestException) catch (BadRequestException)
{ {
// Thrown when the user is already invited to the organization
continue; continue;
} }
} }
} }
}
// Groups // Groups