From e86dd00da56cfc7d8755f5f1f060a4bacbf622dd Mon Sep 17 00:00:00 2001 From: jrmccannon Date: Fri, 28 Mar 2025 10:48:24 -0500 Subject: [PATCH] Calculated seat addition for SM. --- .../Validation/InviteOrganizationUserValidator.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs index ce485d119b..455c8acca1 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs @@ -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(new Error(ex.Message, request)); } + + int GetSecretManagerSeatAdjustment(int occupiedSeats, InviteOrganization organization, int invitesToSend) => + organization.SmSeats - (occupiedSeats + invitesToSend) ?? 0; } }