mirror of
https://github.com/bitwarden/server.git
synced 2025-04-07 14:08:13 -05:00
enough seats available
This commit is contained in:
parent
cadc79b900
commit
fca12ecda6
@ -947,17 +947,16 @@ namespace Bit.Core.Services
|
|||||||
var usersToAdd = newUsersSet.Except(existingUsersSet).ToList();
|
var usersToAdd = newUsersSet.Except(existingUsersSet).ToList();
|
||||||
|
|
||||||
var seatsAvailable = int.MaxValue;
|
var seatsAvailable = int.MaxValue;
|
||||||
|
var enoughSeatsAvailable = true;
|
||||||
if(organization.Seats.HasValue)
|
if(organization.Seats.HasValue)
|
||||||
{
|
{
|
||||||
var userCount = await _organizationUserRepository.GetCountByOrganizationIdAsync(organizationId);
|
var userCount = await _organizationUserRepository.GetCountByOrganizationIdAsync(organizationId);
|
||||||
seatsAvailable = organization.Seats.Value - userCount;
|
seatsAvailable = organization.Seats.Value - userCount;
|
||||||
if(seatsAvailable < usersToAdd.Count)
|
enoughSeatsAvailable = seatsAvailable >= usersToAdd.Count;
|
||||||
{
|
|
||||||
// throw exception?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(enoughSeatsAvailable)
|
||||||
|
{
|
||||||
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))
|
||||||
@ -976,6 +975,7 @@ namespace Bit.Core.Services
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var existingUsersEmailsDict = existingUsersOriginal
|
var existingUsersEmailsDict = existingUsersOriginal
|
||||||
.Where(u => string.IsNullOrWhiteSpace(u.ExternalId))
|
.Where(u => string.IsNullOrWhiteSpace(u.ExternalId))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user