1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-04 20:50:21 -05:00

Calculated seat addition for SM.

This commit is contained in:
jrmccannon 2025-03-28 10:48:24 -05:00
parent 06d091178f
commit e86dd00da5
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6

View File

@ -1,4 +1,5 @@
using Bit.Core.AdminConsole.Errors;
using Bit.Core.AdminConsole.Models.Business;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Models;
using Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUsers.Validation.PasswordManager;
using Bit.Core.AdminConsole.Shared.Validation;
@ -46,8 +47,10 @@ public class InviteUsersValidator(
organization: await organizationRepository.GetByIdAsync(request.InviteOrganization.OrganizationId),
plan: request.InviteOrganization.Plan,
autoscaling: true)
.AdjustSeats(request.Invites.Count(x => x.AccessSecretsManager));
.AdjustSeats(GetSecretManagerSeatAdjustment(
occupiedSeats: request.OccupiedSmSeats,
organization: request.InviteOrganization,
invitesToSend: request.Invites.Count(x => x.AccessSecretsManager)));
await secretsManagerSubscriptionCommand.ValidateUpdateAsync(smSubscriptionUpdate);
@ -60,5 +63,8 @@ public class InviteUsersValidator(
{
return new Invalid<InviteUserOrganizationValidationRequest>(new Error<InviteUserOrganizationValidationRequest>(ex.Message, request));
}
int GetSecretManagerSeatAdjustment(int occupiedSeats, InviteOrganization organization, int invitesToSend) =>
organization.SmSeats - (occupiedSeats + invitesToSend) ?? 0;
}
}