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

Removed valid wrapper to pass in to validation methods.

This commit is contained in:
jrmccannon 2025-03-26 15:57:16 -05:00
parent 8d2c723c09
commit 75c6d2b0dc
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6
2 changed files with 6 additions and 6 deletions

View File

@ -33,12 +33,12 @@ public class InviteUsersValidator(
return invalidSubscriptionUpdate.Map(request); return invalidSubscriptionUpdate.Map(request);
} }
if (ValidateEnvironment(globalSettings, passwordManagerValidationResult as Valid<PasswordManagerSubscriptionUpdate>) is Invalid<IGlobalSettings> invalidEnvironment) if (ValidateEnvironment(globalSettings, subscriptionUpdate) is Invalid<IGlobalSettings> invalidEnvironment)
{ {
return invalidEnvironment.Map(request); return invalidEnvironment.Map(request);
} }
var organizationValidationResult = InviteUserOrganizationValidator.Validate(request.InviteOrganization, passwordManagerValidationResult as Valid<PasswordManagerSubscriptionUpdate>); var organizationValidationResult = InviteUserOrganizationValidator.Validate(request.InviteOrganization, subscriptionUpdate);
if (organizationValidationResult is Invalid<InviteOrganization> organizationValidation) if (organizationValidationResult is Invalid<InviteOrganization> organizationValidation)
{ {
@ -82,8 +82,8 @@ public class InviteUsersValidator(
smSubscriptionUpdate)); smSubscriptionUpdate));
} }
public static ValidationResult<IGlobalSettings> ValidateEnvironment(IGlobalSettings globalSettings, Valid<PasswordManagerSubscriptionUpdate> subscriptionUpdate) => public static ValidationResult<IGlobalSettings> ValidateEnvironment(IGlobalSettings globalSettings, PasswordManagerSubscriptionUpdate subscriptionUpdate) =>
globalSettings.SelfHosted && subscriptionUpdate?.Value.SeatsRequiredToAdd > 0 globalSettings.SelfHosted && subscriptionUpdate.SeatsRequiredToAdd > 0
? new Invalid<IGlobalSettings>(new CannotAutoScaleOnSelfHostError(globalSettings)) ? new Invalid<IGlobalSettings>(new CannotAutoScaleOnSelfHostError(globalSettings))
: new Valid<IGlobalSettings>(globalSettings); : new Valid<IGlobalSettings>(globalSettings);
} }

View File

@ -7,9 +7,9 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse
public static class InviteUserOrganizationValidator public static class InviteUserOrganizationValidator
{ {
public static ValidationResult<InviteOrganization> Validate(InviteOrganization inviteOrganization, public static ValidationResult<InviteOrganization> Validate(InviteOrganization inviteOrganization,
Valid<PasswordManagerSubscriptionUpdate> 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>(inviteOrganization); return new Valid<InviteOrganization>(inviteOrganization);
} }