From 75c6d2b0dc85d145cbcfbd6ede1a80b3924b22a3 Mon Sep 17 00:00:00 2001 From: jrmccannon Date: Wed, 26 Mar 2025 15:57:16 -0500 Subject: [PATCH] Removed valid wrapper to pass in to validation methods. --- .../Validation/InviteOrganizationUserValidator.cs | 8 ++++---- .../Organization/InviteUserOrganizationValidator.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs index f0ce1dbaa1..8575e3825b 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/InviteOrganizationUserValidator.cs @@ -33,12 +33,12 @@ public class InviteUsersValidator( return invalidSubscriptionUpdate.Map(request); } - if (ValidateEnvironment(globalSettings, passwordManagerValidationResult as Valid) is Invalid invalidEnvironment) + if (ValidateEnvironment(globalSettings, subscriptionUpdate) is Invalid invalidEnvironment) { return invalidEnvironment.Map(request); } - var organizationValidationResult = InviteUserOrganizationValidator.Validate(request.InviteOrganization, passwordManagerValidationResult as Valid); + var organizationValidationResult = InviteUserOrganizationValidator.Validate(request.InviteOrganization, subscriptionUpdate); if (organizationValidationResult is Invalid organizationValidation) { @@ -82,8 +82,8 @@ public class InviteUsersValidator( smSubscriptionUpdate)); } - public static ValidationResult ValidateEnvironment(IGlobalSettings globalSettings, Valid subscriptionUpdate) => - globalSettings.SelfHosted && subscriptionUpdate?.Value.SeatsRequiredToAdd > 0 + public static ValidationResult ValidateEnvironment(IGlobalSettings globalSettings, PasswordManagerSubscriptionUpdate subscriptionUpdate) => + globalSettings.SelfHosted && subscriptionUpdate.SeatsRequiredToAdd > 0 ? new Invalid(new CannotAutoScaleOnSelfHostError(globalSettings)) : new Valid(globalSettings); } diff --git a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/Organization/InviteUserOrganizationValidator.cs b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/Organization/InviteUserOrganizationValidator.cs index 9256a80059..1703bde9d3 100644 --- a/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/Organization/InviteUserOrganizationValidator.cs +++ b/src/Core/AdminConsole/OrganizationFeatures/OrganizationUsers/InviteUsers/Validation/Organization/InviteUserOrganizationValidator.cs @@ -7,9 +7,9 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse public static class InviteUserOrganizationValidator { public static ValidationResult Validate(InviteOrganization inviteOrganization, - Valid passwordManagerValidationResult) + PasswordManagerSubscriptionUpdate subscriptionUpdate) { - if (inviteOrganization.Seats is null || passwordManagerValidationResult.Value.SeatsRequiredToAdd is 0) + if (inviteOrganization.Seats is null || subscriptionUpdate.SeatsRequiredToAdd is 0) { return new Valid(inviteOrganization); }