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

Moved XML comment. Added check to see if additional seats are needed.

This commit is contained in:
jrmccannon 2025-03-24 15:24:22 -05:00
parent 038c00d21f
commit f69dc1f7cf
No known key found for this signature in database
GPG Key ID: CF03F3DB01CE96A6
2 changed files with 12 additions and 8 deletions

View File

@ -25,11 +25,6 @@ public class InviteUsersValidator(
{
public async Task<ValidationResult<InviteUserOrganizationValidationRequest>> ValidateAsync(InviteUserOrganizationValidationRequest request)
{
if (ValidateEnvironment(globalSettings) is Invalid<IGlobalSettings> invalidEnvironment)
{
return invalidEnvironment.Map(request);
}
var organizationValidationResult = InvitingUserOrganizationValidator.Validate(request.InviteOrganization);
if (organizationValidationResult is Invalid<InviteOrganization> organizationValidation)
@ -45,6 +40,11 @@ public class InviteUsersValidator(
return invalidSubscriptionUpdate.Map(request);
}
if (ValidateEnvironment(globalSettings, passwordManagerValidationResult as Valid<PasswordManagerSubscriptionUpdate>) is Invalid<IGlobalSettings> invalidEnvironment)
{
return invalidEnvironment.Map(request);
}
var smSubscriptionUpdate = new SecretsManagerSubscriptionUpdate(request, subscriptionUpdate);
var secretsManagerValidationResult = SecretsManagerInviteUserValidation.Validate(smSubscriptionUpdate);
@ -81,8 +81,8 @@ public class InviteUsersValidator(
smSubscriptionUpdate));
}
public static ValidationResult<IGlobalSettings> ValidateEnvironment(IGlobalSettings globalSettings) =>
globalSettings.SelfHosted
public static ValidationResult<IGlobalSettings> ValidateEnvironment(IGlobalSettings globalSettings, Valid<PasswordManagerSubscriptionUpdate> subscriptionUpdate) =>
globalSettings.SelfHosted && subscriptionUpdate?.Value.AdditionalSeats > 0
? new Invalid<IGlobalSettings>(new CannotAutoScaleOnSelfHostError(globalSettings))
: new Valid<IGlobalSettings>(globalSettings);
}

View File

@ -4,7 +4,11 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse
public static class PasswordManagerInviteUserValidator
{
// NOTE This is only for validating adding users to an organization, not removing
/// <summary>
/// This is for validating if the organization can add additional users.
/// </summary>
/// <param name="subscriptionUpdate"></param>
/// <returns></returns>
public static ValidationResult<PasswordManagerSubscriptionUpdate> Validate(PasswordManagerSubscriptionUpdate subscriptionUpdate)
{
if (subscriptionUpdate.Seats is null)