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:
parent
038c00d21f
commit
f69dc1f7cf
@ -25,11 +25,6 @@ public class InviteUsersValidator(
|
|||||||
{
|
{
|
||||||
public async Task<ValidationResult<InviteUserOrganizationValidationRequest>> ValidateAsync(InviteUserOrganizationValidationRequest request)
|
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);
|
var organizationValidationResult = InvitingUserOrganizationValidator.Validate(request.InviteOrganization);
|
||||||
|
|
||||||
if (organizationValidationResult is Invalid<InviteOrganization> organizationValidation)
|
if (organizationValidationResult is Invalid<InviteOrganization> organizationValidation)
|
||||||
@ -45,6 +40,11 @@ public class InviteUsersValidator(
|
|||||||
return invalidSubscriptionUpdate.Map(request);
|
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 smSubscriptionUpdate = new SecretsManagerSubscriptionUpdate(request, subscriptionUpdate);
|
||||||
var secretsManagerValidationResult = SecretsManagerInviteUserValidation.Validate(smSubscriptionUpdate);
|
var secretsManagerValidationResult = SecretsManagerInviteUserValidation.Validate(smSubscriptionUpdate);
|
||||||
|
|
||||||
@ -81,8 +81,8 @@ public class InviteUsersValidator(
|
|||||||
smSubscriptionUpdate));
|
smSubscriptionUpdate));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ValidationResult<IGlobalSettings> ValidateEnvironment(IGlobalSettings globalSettings) =>
|
public static ValidationResult<IGlobalSettings> ValidateEnvironment(IGlobalSettings globalSettings, Valid<PasswordManagerSubscriptionUpdate> subscriptionUpdate) =>
|
||||||
globalSettings.SelfHosted
|
globalSettings.SelfHosted && subscriptionUpdate?.Value.AdditionalSeats > 0
|
||||||
? new Invalid<IGlobalSettings>(new CannotAutoScaleOnSelfHostError(globalSettings))
|
? new Invalid<IGlobalSettings>(new CannotAutoScaleOnSelfHostError(globalSettings))
|
||||||
: new Valid<IGlobalSettings>(globalSettings);
|
: new Valid<IGlobalSettings>(globalSettings);
|
||||||
}
|
}
|
@ -4,7 +4,11 @@ namespace Bit.Core.AdminConsole.OrganizationFeatures.OrganizationUsers.InviteUse
|
|||||||
|
|
||||||
public static class PasswordManagerInviteUserValidator
|
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)
|
public static ValidationResult<PasswordManagerSubscriptionUpdate> Validate(PasswordManagerSubscriptionUpdate subscriptionUpdate)
|
||||||
{
|
{
|
||||||
if (subscriptionUpdate.Seats is null)
|
if (subscriptionUpdate.Seats is null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user