Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-14365][Defect] Member of trialing org cannot log in app #4967

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ namespace Bit.Api.Billing.Models.Responses;
public record OrganizationMetadataResponse(
bool IsEligibleForSelfHost,
bool IsManaged,
bool IsOnSecretsManagerStandalone)
bool IsOnSecretsManagerStandalone,
bool IsSubscriptionUnpaid)
{
public static OrganizationMetadataResponse From(OrganizationMetadata metadata)
=> new(
metadata.IsEligibleForSelfHost,
metadata.IsManaged,
metadata.IsOnSecretsManagerStandalone);
metadata.IsOnSecretsManagerStandalone,
metadata.IsSubscriptionUnpaid);
}
3 changes: 2 additions & 1 deletion src/Core/Billing/Models/OrganizationMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public record OrganizationMetadata(
bool IsEligibleForSelfHost,
bool IsManaged,
bool IsOnSecretsManagerStandalone);
bool IsOnSecretsManagerStandalone,
bool IsSubscriptionUnpaid);
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@ public async Task Finalize(OrganizationSale sale)
return null;
}

var customer = await subscriberService.GetCustomer(organization, new CustomerGetOptions
{
Expand = ["discount.coupon.applies_to"]
});
var customer = await subscriberService.GetCustomer(organization,
new CustomerGetOptions { Expand = ["discount.coupon.applies_to"] });

var subscription = await subscriberService.GetSubscription(organization);

var isEligibleForSelfHost = IsEligibleForSelfHost(organization);
var isManaged = organization.Status == OrganizationStatusType.Managed;
var isOnSecretsManagerStandalone = IsOnSecretsManagerStandalone(organization, customer, subscription);
var isSubscriptionUnpaid = IsSubscriptionUnpaid(subscription);

return new OrganizationMetadata(isEligibleForSelfHost, isManaged, isOnSecretsManagerStandalone);
return new OrganizationMetadata(isEligibleForSelfHost, isManaged, isOnSecretsManagerStandalone,
isSubscriptionUnpaid);
}

public async Task UpdatePaymentMethod(
Expand Down Expand Up @@ -376,5 +376,16 @@ private static bool IsOnSecretsManagerStandalone(
return subscriptionProductIds.Intersect(couponAppliesTo ?? []).Any();
}

private static bool IsSubscriptionUnpaid(Subscription subscription)
{
if (subscription == null)
{
return false;
}

return subscription.Status == "unpaid";
}


#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task GetMetadataAsync_OK(
{
sutProvider.GetDependency<ICurrentContext>().AccessMembersTab(organizationId).Returns(true);
sutProvider.GetDependency<IOrganizationBillingService>().GetMetadata(organizationId)
.Returns(new OrganizationMetadata(true, true, true));
.Returns(new OrganizationMetadata(true, true, true, true));

var result = await sutProvider.Sut.GetMetadataAsync(organizationId);

Expand Down
Loading