mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
[AC-2420] Fix customer discount ID and SM invite validation (#3966)
* Fix customer discount ID and SM update validation * Replace constructor needed for autofixture
This commit is contained in:
parent
49ed5af517
commit
9827ee5f6a
@ -43,20 +43,12 @@ public class SubscriptionResponseModel : ResponseModel
|
||||
public DateTime? Expiration { get; set; }
|
||||
}
|
||||
|
||||
public class BillingCustomerDiscount
|
||||
public class BillingCustomerDiscount(SubscriptionInfo.BillingCustomerDiscount discount)
|
||||
{
|
||||
public BillingCustomerDiscount(SubscriptionInfo.BillingCustomerDiscount discount)
|
||||
{
|
||||
Id = discount.Id;
|
||||
Active = discount.Active;
|
||||
PercentOff = discount.PercentOff;
|
||||
AppliesTo = discount.AppliesTo;
|
||||
}
|
||||
|
||||
public string Id { get; }
|
||||
public bool Active { get; }
|
||||
public decimal? PercentOff { get; }
|
||||
public List<string> AppliesTo { get; }
|
||||
public string Id { get; } = discount.Id;
|
||||
public bool Active { get; } = discount.Active;
|
||||
public decimal? PercentOff { get; } = discount.PercentOff;
|
||||
public List<string> AppliesTo { get; } = discount.AppliesTo;
|
||||
}
|
||||
|
||||
public class BillingSubscription
|
||||
|
@ -1037,7 +1037,6 @@ public class OrganizationService : IOrganizationService
|
||||
{
|
||||
smSubscriptionUpdate = new SecretsManagerSubscriptionUpdate(organization, true)
|
||||
.AdjustSeats(additionalSmSeatsRequired);
|
||||
await _updateSecretsManagerSubscriptionCommand.ValidateUpdate(smSubscriptionUpdate);
|
||||
}
|
||||
|
||||
var invitedAreAllOwners = invites.All(i => i.invite.Type == OrganizationUserType.Owner);
|
||||
@ -1133,12 +1132,14 @@ public class OrganizationService : IOrganizationService
|
||||
throw new BadRequestException("Cannot add seats. Cannot manage organization users.");
|
||||
}
|
||||
|
||||
await AutoAddSeatsAsync(organization, newSeatsRequired, prorationDate);
|
||||
|
||||
if (additionalSmSeatsRequired > 0)
|
||||
{
|
||||
smSubscriptionUpdate.ProrationDate = prorationDate;
|
||||
await _updateSecretsManagerSubscriptionCommand.UpdateSubscriptionAsync(smSubscriptionUpdate);
|
||||
}
|
||||
await AutoAddSeatsAsync(organization, newSeatsRequired, prorationDate);
|
||||
|
||||
await SendInvitesAsync(orgUsers.Concat(limitedCollectionOrgUsers.Select(u => u.Item1)), organization);
|
||||
|
||||
await _referenceEventService.RaiseEventAsync(
|
||||
|
@ -14,16 +14,16 @@ public class SubscriptionInfo
|
||||
|
||||
public BillingCustomerDiscount(Discount discount)
|
||||
{
|
||||
Id = discount.Id;
|
||||
Active = discount.Start != null && discount.End == null;
|
||||
Id = discount.Coupon?.Id;
|
||||
Active = discount.End == null;
|
||||
PercentOff = discount.Coupon?.PercentOff;
|
||||
AppliesTo = discount.Coupon?.AppliesTo?.Products ?? new List<string>();
|
||||
AppliesTo = discount.Coupon?.AppliesTo?.Products ?? [];
|
||||
}
|
||||
|
||||
public string Id { get; }
|
||||
public bool Active { get; }
|
||||
public decimal? PercentOff { get; }
|
||||
public List<string> AppliesTo { get; }
|
||||
public string Id { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public decimal? PercentOff { get; set; }
|
||||
public List<string> AppliesTo { get; set; }
|
||||
}
|
||||
|
||||
public class BillingSubscription
|
||||
|
@ -5,5 +5,4 @@ namespace Bit.Core.OrganizationFeatures.OrganizationSubscriptions.Interface;
|
||||
public interface IUpdateSecretsManagerSubscriptionCommand
|
||||
{
|
||||
Task UpdateSubscriptionAsync(SecretsManagerSubscriptionUpdate update);
|
||||
Task ValidateUpdate(SecretsManagerSubscriptionUpdate update);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class UpdateSecretsManagerSubscriptionCommand : IUpdateSecretsManagerSubs
|
||||
|
||||
public async Task UpdateSubscriptionAsync(SecretsManagerSubscriptionUpdate update)
|
||||
{
|
||||
await ValidateUpdate(update);
|
||||
await ValidateUpdateAsync(update);
|
||||
|
||||
await FinalizeSubscriptionAdjustmentAsync(update);
|
||||
|
||||
@ -123,7 +123,7 @@ public class UpdateSecretsManagerSubscriptionCommand : IUpdateSecretsManagerSubs
|
||||
|
||||
}
|
||||
|
||||
public async Task ValidateUpdate(SecretsManagerSubscriptionUpdate update)
|
||||
private async Task ValidateUpdateAsync(SecretsManagerSubscriptionUpdate update)
|
||||
{
|
||||
if (_globalSettings.SelfHosted)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user